function gettarget() {
//Validates whether a number is supplied is actually a number
var targetform = document.testtool.target.value;
if (targetform == ""||isNaN(targetform))
{ alert("Please enter the number of the target form and retry Load Form button");
}
else
{
return(targetform);
}
}

function loadforms()
{
// Function to fill fields on forms
var rawstring = document.testtool.result.value;// Copy text from copy paste area of testtool form.

var cleanup = /(\s+)$/ig; //Remove white space and carriage returns from the end of the text string.

var getdata = rawstring.replace(cleanup,"");// replace white space with an empty string



var z = gettarget();// It is possible that there may be more than one form on the page



var record = new Array();
var ctrlname = new Array();
record = getdata.split("\r\n"); //Separate into records by looking for Carriage return and line feed chr$ 13 chr$10
ctrlname = record[0].split(",") ; //First record in array are names of controls on form


var recnum= record.length;

for(var cnt= 1;cnt< recnum;cnt++)
{
var datavalu = new Array();
datavalu = record[cnt].split(",") ;
var elementcnt = datavalu.length;
var nextrecord = 14;
window.frames['appwindow'].document.forms[z].elements[nextrecord].click();
var frmelement = "";

//For each record enter data into form.
for(var i =0; i <elementcnt; i++)
{
// Remove white spaces in order to do proper comparison.
var cleanup = /^(\s+)|(\s+)$/ig; //identify white space at the front and back of field names.

var rawstring = ctrlname[i]; // Identify field to update name element

frmelement = rawstring.replace(cleanup,"");// replace white space with an empty string

//alert (frmelement + " " +datavalu[i] + " " + window.frames['appwindow'].document.forms[z].elements[i].name);

window.frames['appwindow'].document.forms[z][frmelement].value =datavalu[i];

}// end of i loop
var addrecord = 16; // number of add record button in the Form array. Will vary depending on form

window.frames['appwindow'].document.forms[z].elements[addrecord].click();

}// end of cnt loop

}// end of function loadforms

Test Tool Form

<FORM NAME = "testtool" >

<P>Enter Web Address of Form and click load form. If blank then the default form will load. <BR />
<INPUT TYPE = "button" VALUE = "Load Form" onClick ="loadIframe('appwindow')" >

<INPUT TYPE="text" NAME = "webaddr" SIZE="70" /> </P>
<P>

<INPUT TYPE = "button" VALUE= "Clear Text Area Below" onClick ="clrArea()" />
<INPUT TYPE = "button" VALUE= "Analyze Form" onClick ="listformobjects()" />

<BR />

<LABEL> Copy and Paste Area </LABEL> <BR />
<TEXTAREA NAME = "result" ROWS="12" COLS="90" > </TEXTAREA>
<BR />
Target Form Array Number <INPUT TYPE="text" NAME = "target" SIZE="1" MAXLENGTH ="1" VALUE="0" />
<INPUT TYPE = "button" VALUE= "Run New Record Script" onClick ="loadforms()" >
</P>
</FORM>

Hosted by www.Geocities.ws

1