How can I use web browser windows from RAMP scripts?
Here's a really simple web browser form that accepts three input fields as arguments, displays them, allows them to be altered, then returns the altered values back to the calling RAMP script:
<HTML>
<HEAD>
</HEAD>
<BODY onload="BODY_Load();" onunload="BODY_UnLoad();" >
<script>
function BODY_Load() /* Map arguments passed in to web form fields */
{
FieldA.value = window.dialogArguments[0];
FieldB.value = window.dialogArguments[1];
FieldC.value = window.dialogArguments[2];
}
function BODY_UnLoad() /* Map web form fields into return values */
{
var arrayRets = new Array();
arrayRets[0] = FieldA.value;
arrayRets[1] = FieldB.value;
arrayRets[2] = FieldC.value;
window.returnValue = arrayRets;
}
function OK_Click() /* Handle OK button by closing the web form */
{
window.close();
}
</script>
<P>Input details and click OK"<br/>
<input id="FieldA" type="text"><br/>
<input id="FieldB" type="text"><br/>
<input id="FieldC" type="text"><br/>
<input id="Button1" type="button" value=" OK " onclick="OK_Click();">
</BODY>
</HTML>
It looks like this when displayed:
This is the RAMP BUTTON script that is used to display the web browser form. It displays the form when the user hits F5, taking the fields SURNAME, GIVENAME and ADDRESS1 from the 5250 form and then mapping them back:
switch (objScriptInstance.FunctionKeyUsed)
{
case KeyEnter:
SENDKEY(KeyEnter);
break;
case KeyF5:
{
var arrayArgs = new Array();
arrayArgs[0] = GETVALUE("SURNAME");
arrayArgs[1] = GETVALUE("GIVENAME");
arrayArgs[2] = GETVALUE("ADDRESS1");
arrayRets = window.showModalDialog("Example.htm",arrayArgs,"dialogHeight:155px;dialogWidth:200px;help:no;resizable:no;scroll:no;status:no;");
SETVALUE("SURNAME",arrayRets[0]);
SETVALUE("GIVENAME",arrayRets[1]);
SETVALUE("ADDRESS1",arrayRets[2]);
delete(arrayArgs);
delete(arrayRets);
}
break;
default:
SENDKEY(objScriptInstance.FunctionKeyUsed);
break;
}
This is just a simple example of some of the things you can do (please note that no warranty about any of this is expressed or implied).