Forum Moderators: open
I have a form which calls a script, let's say:-
<form action="http://example.com/submit.php">
<input type="submit" name="blah">
<elements>
</form>
.... and I want to take the result from submit.php and dynamically incorporate it into the page without redirecting to a new page.
I'm currently thinking along the following lines:-
<form action="http://example.com/submit.php"><div id="tj"><input type="submit" name="blah"></div>
<elements>
</form>
And when the form is submitted, the result is "pushed" into the DIV id "tj" with a:-
document.getElementById("tj").innerHTML="<result of the form submit>"
I know that I can do a popup using _target="blank" but I'm trying to avoid that - really I want this dynamically pushed into the existing page.
Possible? If not, any lateral thinking ideas also gratefully received!
Thanks,
TJ
<form id="ExampleForm"
action="http://example.com/submit.php" target="Results" method="post">
..
Form Elements
..
</form>
<iframe name="Results"></iframe>
Use a piece of suitable styling for your IFRAME and it will practically achieve exactly what you want.
TexMex - I've been thinking about ways I could use an iFrame, but the problem is I don't think that the content of the iFrame can reference the containing pages form?
eg, I couldn't put the "submit" button for the form in the page source of the iFrame, if that makes sense.
AJAX might indeed be the only answer here for what I really want to try and achieve (which is an effect as much as anything).
Any script in the document of the IFRAME is also able to access it's parent document (assuming the page is from the same site).
So potentially, your recieving document could process the fields it has been fed and then EVEN update parts of it's parent document.
In fact. You could even leave the IFRAME invisible at all times, and use an onload function of your recieving page to update that DIV that you want.
If you're interested I'll knock up a quick couple of pages to post as a demo.
Thanks but it's OK now - got it all worked out. You're right, I discovered I could reference the iFrames parent form objects, but it was hassle and additional code. I worked out a simpler way in the event (often when something gets too complicated it means your design is bad in the first place :) )
TJ
Anyhow, I don't know enough about your application to leap to any conclusions, but glad you got it sorted.