...

View Full Version : posting parent and iframe from parent



bhakti_thakkar
08-27-2010, 01:14 PM
Hello all,
I have a page which has a form and also one iframe in the same. there is a button on the parent form.
when the button is clicked, i am submitting the iframe and parent both. forms are getting submitted. but when i do print_r for iframe values, it is blank

below is the code

Parent page:



<?
print "<pre>";
print_r($_POST);
print "</pre>";
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--
function validate(){
document.getElementById('mainform').submit();
window.frames['iframe1'].document.forms[0].submit();
}
//-->
</SCRIPT>
<BODY>
<FORM METHOD=POST ACTION="" name='mainform' id='mainform'>
<TABLE>
<TR>
<TD>Name</TD>
<TD><INPUT TYPE="text" NAME="Name_VC"></TD>
</TR>
<TR>
<TD>Address</TD>
<TD><INPUT TYPE="text" NAME="Address_VC"></TD>
</TR>
<TR>
<TD colspan=2><INPUT TYPE="button" name="proceed" value="Save" onClick="validate();"></TD>

</TR>
</TABLE>
</FORM>
<iframe src="test1.php" id='iframe1'></iframe>
</BODY>
</HTML>




iframe page : test1.php


<?
print "<pre>";
print_r($POST);
print "</pre>";
?>
<form name='mainform2' id='mainform2' method='post' action=''>
Roll number : <INPUT TYPE="text" NAME="Rollnum" value=''>
Age: <INPUT TYPE="text" NAME="Age_IN" value=''>
</form>



Please tell me what is my mistake or how can i achieve values of all 4 fields
Million thanks

Arty Effem
08-27-2010, 05:29 PM
Try submitting the iframe before dismissing its parent:
<script type='text/javascript'>

function validate()
{
window.frames['iframe1'].document.forms[0].submit();
document.getElementById('mainform').submit();
}

</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum