I'm hoping there is a way to do this...
I have a complicated legacy function written in java which, with minor tweaks, I've converted into javascript. I would like to leverage its functionality in one of our Vortex pages. The output of the function is a single string. My question is how to get the output of the function into a Vortex variable so that I can use it in the enclosing Vortex code. I see that there has been some discussion of this on the message boards in the past, but I can't put my finger on the solution, if there is one.
Here is my attempt at a "proof of concept", which is not working. Upon a click of the button, the embedded script is called. Its return value is what I would like to use in the vortex code. (The actual function is MUCH more complicated, and its return value is dependent on the value being passed to the function.) In this overly simplified example the javascript writes the return value to a textbox on the form. I'd much prefer instead for the value to be written to a vortex variable to be referenced as, say, $myReturnValue, but how to do that is what has me stumped. As you can see, referencing the value of the textbox doesn't work either (which also confuses me!)
Of course, I could translate the entire legacy function into Vortex and that would probably solve the problem. But good lord...! That's a lot of rewrite!
Thanks for your help.
<script language=Vortex>
<a name=main PUBLIC>
<LoadForm>
</a>
<a name=LoadForm PUBLIC>
<verb noesc>
<script language=JavaScript>
function myLongFunction(someValue) {
//Actual function is much more complicated and return value depends on input value
var sReturn = "My return value";
document.getElementById('resultID').value = sReturn;
}
</script>
</verb>
<form name=myform method=post action="$url">
<input type=text name=inputValue style="width:150"><br>
<input onclick="myLongFunction($inputValue)" type="button" value="Show Result" style="width:150"> <br>
<input type=text id="resultID" name=theResult disabled style="width:500"> <br>
The return value of the function is: [$theResult]<br>
</form>
</a>
</script>
I have a complicated legacy function written in java which, with minor tweaks, I've converted into javascript. I would like to leverage its functionality in one of our Vortex pages. The output of the function is a single string. My question is how to get the output of the function into a Vortex variable so that I can use it in the enclosing Vortex code. I see that there has been some discussion of this on the message boards in the past, but I can't put my finger on the solution, if there is one.
Here is my attempt at a "proof of concept", which is not working. Upon a click of the button, the embedded script is called. Its return value is what I would like to use in the vortex code. (The actual function is MUCH more complicated, and its return value is dependent on the value being passed to the function.) In this overly simplified example the javascript writes the return value to a textbox on the form. I'd much prefer instead for the value to be written to a vortex variable to be referenced as, say, $myReturnValue, but how to do that is what has me stumped. As you can see, referencing the value of the textbox doesn't work either (which also confuses me!)
Of course, I could translate the entire legacy function into Vortex and that would probably solve the problem. But good lord...! That's a lot of rewrite!
Thanks for your help.
<script language=Vortex>
<a name=main PUBLIC>
<LoadForm>
</a>
<a name=LoadForm PUBLIC>
<verb noesc>
<script language=JavaScript>
function myLongFunction(someValue) {
//Actual function is much more complicated and return value depends on input value
var sReturn = "My return value";
document.getElementById('resultID').value = sReturn;
}
</script>
</verb>
<form name=myform method=post action="$url">
<input type=text name=inputValue style="width:150"><br>
<input onclick="myLongFunction($inputValue)" type="button" value="Show Result" style="width:150"> <br>
<input type=text id="resultID" name=theResult disabled style="width:500"> <br>
The return value of the function is: [$theResult]<br>
</form>
</a>
</script>