The following function tests to see if a form is loaded before working within the form.
function TargetLoaded(obj)
{
var stat = (obj !=null)
// determine status, if the form is loaded and not equal to null
if (!stat)
{
alert("The form is not loaded, please wait a moment and try again.");
return stat
} // end of conditional
} // end of TargetLoaded()
function writeToForm()
{
var autoform = document.forms[0]
if (TargetLoaded(autoform))
{
// Code to work form here.
} // of conditional
}// end of writeToForm()
setting a value
window.frames['iframe name'].document.forms[0].elements[array id].value = somevariable;
someothervar = window.frames['iframe name'].document.forms[0].elements[array id].value ;
window.frames['iframe name'].document.forms[z]['control Name'].value =datavalu[i];
var thistext = alltext.value;
thistext = thistext.toUpperCase()
thattext = thattext.toLowerCase()
toString() creates a string from elements of an array separated by commas.
contact = new Array("Peter","George","Matt");
alert(contact.toString()); //would return Peter,George,Matt
var substring_name = string_name.substr(start_position, substring_length);
var substring_name = string_name.substring(start_position, end_position);
function enterHTML(passed)
{
var targt = passed; //value passed is the DIV id 'targetloc'
var initial = document.getElementById(targt) ;
initial.innerHTML = "<P>New Form <\/P> \n <FORM> <INPUT TYPE = 'button'" + " VALUE = 'Test Me'" +'onClick = "alert' + "('it works')"+ '"'+ "> <\/FORM>";
var textresult =initial.innerText;
}
Click to demonstrate the innerHTML function.
This text to be replaced by a form with a button.
| Syntax | ___ | Character | Comment |
|---|---|---|---|
| \n | new line | Makes the resulting code more readable | |
| \r | carriage return | ||
| \' | single quote | ||
| \" | quotation marks | ||
| \/ | back slash | Used in closing an html element </p> would be <\/p> | |