Passing JS variables to hidden fields

admin

Administrator
Staff member
Hi,

I have two frames. The top frame extracts input values from the bottom frame and submits it to a form handler.

My problem is that I can't get the values from the bottom frame into hidden fields to be submitted. My code is below:

Thanks for the help. Greatly appreciated!

Frameset
------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<frameset rows="50,*" frameborder="NO" border="0" framespacing="0">
<frame src=http://www.webdeveloper.com/forum/archive/index.php/"LetterTop.cfm" name="TopFrame" scrolling="NO" noresize >
<frame src="LetterBody.cfm" name="BodyFrame">
</frameset>
<noframes><body>

</body></noframes>
</html>



BodyFrame
------------------
<FORM NAME="formtwo">
Enter some text: <INPUT TYPE="text" NAME="test1"><br>
Enter some text: <INPUT TYPE="text" NAME="test2">
<P><INPUT TYPE="BUTTON" VALUE="Submit">
</FORM>



TopFrame
-------------
<SCRIPT LANGUAGE="JavaScript">
<!--

function store_info(){
var document.formone.hide1.value=top.frames[1].formtwo.test1.value;
var document.formone.hide1.value=top.frames[1].formtwo.test2.value;
document.formone.submit();

//-->
}
</SCRIPT>

<FORM NAME="formone" action="test.cfm">
Enter some text: <INPUT TYPE="text" NAME="test3">
<INPUT TYPE="HIDDEN" NAME="hide1">
<INPUT TYPE="HIDDEN" NAME="hide2">
<P>
<INPUT TYPE="BUTTON" VALUE="Submit" onClick="store_info()">

</FORM>
 
Back
Top