View Full Version : submitting form in iframe from main page not working right

11-30-2006, 10:48 PM
I have an IFrame that contains a form and a link on the main page to submit the form in the IFrame. If I use a submit button in the form in the IFrame, then the form submits properly. It does not work properly if I try to submit with JavaScript from the main page. The form in the IFrame posts back to the same page. I have supplied some code snippets below. They are not complete. Just examples to show the problem.

You can see there is an alert to display the contents of notes_1 on the form submit within the IFrame. There is also an alert at the end of the IFrame page to show the contents of note_1 upon load. If I change the contents of notes_1 and press the submit button in the IFrame, the first alert will show me the current content of notes_1 (the changed value). Upon reloading, the alert shows the contents of notes_1 to be the original value from the db because I'm not actually saving changes yet.

You see that all the Save link does on the main page is click the same submit button I pushed manually above. But when I do this the alert shows me the OLD value of notes_1 before I typed in something else. The alert on the bottom of the IFrame page happens showing that the page has reloaded, but IT DOESN'T REFRESH THE IFRAME. The IFrame continues to show what I typed into the field before pressing the Save link.

Two things I do not understand: 1) Why does posting from the main page give me an alert with the old value? and 2) why does the IFrame not refresh upon the post? The post was successful but the IFrame doesn't show so.

This is HTTPS if that makes any difference.


<!-- This is the main doc snippet -->
<legend>&nbsp;Emergency Contacts&nbsp;&nbsp;<a href="#" onclick="SaveEmergencyContacts(); return false;">[Save]</a>&nbsp;</legend>
<iframe SRC="EmergencyContacts.php" name="ECIframe" id="ECIframe" width="622" height="210" frameborder="0"></iframe>

function SaveEmergencyContacts()


<!-- This is the IFrame snippet -->
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form action="EmergencyContacts.php" method="post" name="ECForm" id="ECForm"
<input type"text" name="notes_1" id="notes_1" value="This is a test">
<input type="submit" name="test" id="test" value="Click Me">


12-02-2006, 11:07 AM