HTML and JavaScript

Plugin_form2Embed.html

This HTML file is intended to simplify starting Rexx programs from JavaScript. It is used to dynamically create an HTML page with an EMBED tag to run a Rexx program. The file is "called" in a WINDOW.OPEN('Plugin_form2Embed.html',...) statement in the JavaScript program.

Plugin_form2Embed.html builds the page and the EMBED parameters from JavaScript variables and HTML INPUT and TEXTAREA tags in the JavaScript program that "called" Plugin_form2Embed.html, i.e. the OPENER program. The "standard" EMBED tag parameters are taken from JavaScript variables of the same name defined in the opener document. Please note that JavaScript variable names are case sensitive and the names variables that are to make up the "standard" parameters must be in all lowers The user defined parameters are taken from the INPUT and TEXTAREA tags/screen "controls" of the <FORM> on the opener document. The names in the <FORM> tag are also case sensitive .

Two special JavaScript variables control how the page looks that is built by Plugin_form2Embed.html, three special parameter affect how Plugin_form2Embed.html handles values from the <FORM> "fields".

  1. before_htmlstring and
  2. after_htmlstring can contain HTML that is output before and/or after the EMBED tag.
  3. formObj controls whether "fields" from the <FORM> should be used, and which form should be used if more than one form exists in the OPENER document. When formObj=NONE no user defined parameter are created. If formObj is not defined, the first form in the OPENER document is used, i.e. document.forms[0]. If formObj equals any other value that value must be a reference to a form on the OPENER document that contains "fields" (INPUT and TEXTAREA tags) that are to be made into user defined parameters.
  4. newlinecharacter = "string". The textarea type of control is similar to the OS/2 multiline edit control, in that the user can type multiple lines of text in the control When the data is transferred to a parameter string value the newline characters are stripped out and replaced with the string specified in newlinecharacter. The default string is a single space character. You do not need to specify this variable unless you want to change the default.
  5. separationcharacter = "character" When multiple values are selected in a multi-select list, the values are concatenated together into a single string value that is passed as the parameter for that select list. The variable separationcharacter allows you to specify a character to be used to delimit the values in the string. The default separationcharacter is the semicolon. You do not need to specify a separationcharacter unless you want to change the default.

Example

The first example starts the Rexx program dothis.rex with no user defined parameters.

<html>
<body>
</body>
<script>
var type = 'x-warpdoctor/rexx'
var src = 'http://www.warpdoctor.org/dothis.rex'
var width = 400
var height = 600
var name='program1'
var formObj='NONE'
function makeEmbed()
{   
    win = window.open("plugin_form2embed.html","win1")
}
</script>
</html>

This next example releases a suspended Rexx program passing one parameter zoning as a JSVar variable to the waiting program. The suspended Rexx program is named showZoning.

<html>
<body>
<form>
<input type='hidden' name='zoning' value='R5' >
</form>
</body>
<script>
var type = 'x-warpdoctor/execute'
var width = 400
var height = 600
var formObj='NONE'
var releaseInstance='showZoning'
function makeEmbed()
{   
    win = window.open("plugin_form2embed.html","win1")
}
</script>
</html>

The Plugin_form2Embed.html file is shown below.

<html>
<script language="JavaScript" src="http://www.warpdoctor.org/plugin_form2embed.js"></script>
<script>
if (opener.title != undefined) document.write("<title>",opener.title,"</title>");
</script>
<body>
<script>
if (opener.before_htmlstring != undefined)  document.write(opener.before_htmlstring)
form2embed()
if (opener.after_htmlstring != undefined)  document.write(opener.after_htmlstring)
</script>
</body>
</html>

form2Embed()

The JavaScript function form2Embed() does the actual creation of the EMBED and its parameters. It is called by Plugin_form2Embed.html to create the EMBED.

You can create your own version of Plugin_form2Embed.html if the before_htmlstring and after_htmlstring "special" variables do not provide enough flexibility to create your page the way you want. Just call form2Embed() from somwhere in your HTML page to create the EMBED