Hi everyone.
I'm attempting to write a Javascript that will create a form within a
brand-new document in a specific frame of a frameset. The problem is
that I can create the form and input element using createElement() , but
when I go to append the form element into the new document, the script
halts and I get the following error in my Javascript Console (Firefox 1.0):
__tmp_newDoc.bo dy has no properties.
Here is the frameset definition:
Code:
<frameset rows="30%,30%,* " border="1" noresize>
<frame src="" name="FRAME01" border="1"/>
<frame src="" name="FRAME02" border="1"/>
<frame src="framedom02 .html" name="FRAME03" border="1"/>
</frameset>
framedom02.html essentially just loads the Javascript library and calls
a function from onLoad in the BODY tag.
The javascript being used is as follows:
Code:
function createForm()
{
_TMP_FORMNAME = "form01";
// Open a new document for FRAME02.
__tmp_newDoc = parent.frames['FRAME02'].document.open( );
__tmp_htmlObj = __tmp_newDoc.cr eateElement("ht ml");
alert("Created HTML Object");
__tmp_bodyObj = __tmp_newDoc.cr eateElement("bo dy");
alert("Created BODY Object");
// Create a Form Object.
__tmp_formObj = __tmp_newDoc.cr eateElement("fo rm");
__tmp_formObj.n ame = _TMP_FORMNAME;
__tmp_formObj.a ction = "framehandler02 .php";
__tmp_formObj.m ethod = "post";
__tmp_formObj.t arget = "FRAME01";
alert("Created FORM Object");
// Create an Input Element object.
__tmp_input01 = __tmp_newDoc.cr eateElement("in put");
__tmp_input01.t ype = "text";
__tmp_input01.v alue = "BLAH";
__tmp_input01.n ame = "FRMTXT01";
alert("Created INPUT Object");
// Append the Input element object to the Form Object.
__tmp_formObj.a ppendChild(__tm p_input01);
alert("Appended INPUT to FORM");
__tmp_bodyObj.a ppendChild(__tm p_formObj);
alert("Appended FORM to BODY");
__tmp_htmlObj.a ppendChild(__tm p_bodyObj);
alert("Appended BODY to HTML");
// Append the Form Object to the document body.
__tmp_newDoc.ap pendChild(__tmp _htmlObj);
alert("Appended HTML to Document");
// Close the new document in FRAME02
__tmp_newDoc.cl ose();
}
.... it NEVER makes it to the last Alert. I've tried a few other ways of
doing it, but haven't had any results with them either. What am I doing
wrong here?
Thanks,
- skubik.