Ajax.

There is a handy plugin out there - ajaxForms (I think...) that will allow your existing form to be submitted via ajax, and a callback function executed with the resulting page output. I haven't used it, so probably have the name, and details wrong. (I just write my own Ajax routines for this sort of thing.) But, I know this plugin would do the trick for you.

Failing that, look into the $.ajax() method - you can easily use it to submit a form without reloading your page.

how to use the Ajax powerhouse $.ajax():
http://jquery.open2space.com/node/27

How to work with Ajax (overview):
http://jquery.open2space.com/node/56
(though there are probably better Ajax tutorials out there than this one)

(disclaimer/shameless plug alert! - I wrote both those links)

ALTERNATIVELY, if you don't want to use Ajax, you can make creative use of a iframe (or is that what you meant by "jframes"?). Give your form a "target" attribute - just like you would with an anchor tag - but use the NAME (not ID) attribute of the iframe as your target.

i.e.

<form name="myForm" action="mypage.php" method="post" target="myFrame">
...</form>

<iframe name="myFrame" id="myFrame">

(I like to use the same text for both the name and ID attribute - I often need to refer to the IFrame as a target (which needs the NAME), and/or I might need to access the frame from code (which needs the ID).

Once you get that going, then you can include some JS in the frame's document (your action page) to update the parent page ( window.parent.getElementById("xxx").style.display="none";... or whatever you need)

HTH

Shawn

Steve Good wrote:
Hello,

I am looking for a solution to submit a form and instead of refreshing the whole page just refresh the contents of a div tag. Can anyone point me in the right direction? I tried jframes, but I can't figure out how to get the form to not open a new window.

Thanks in advance!  Let me know if more information is needed.

Reply via email to