Latest Lists

How to make a simple comment form post to the same page?

I would like to make a simple comment form (Name field, Comment field, Submit button) at the top of a page, and then when the person hits Submit it will post that comment at the top of a list of comments just below that form, on the same page. How would I send up the form, and how would i set up the part of the page that it posts to? Thanks.

Public Comments

  1. If you don't want to reload the page, you have to do it using AJAX. Set-up a <div id="upddiv">, on which you show the form itself at start. When you hit "submit", you do NOT submit the form: you call a javascript that makes an Httprequest. The response comes back from the server, and replaces the contents of your "upddiv". This means that the form is like this: <div id="upddiv"> <form name="frm"> => note: NO action the form here <button name = "send" onclick = "js_submit(document.forms['frm']; return false;" > SUBMIT </button> </form> </div> <script> function js_submit(theForm) { Send the form as an httprequest. The reply replaces the contents of <div upddiv> } </script> Go to http://www.web2coders.com and download the Miniblog script: it does something very similar and will be easy to adapt to your needs. (of course, I assume that you have server side scripts and databases: your comments have to be stored there...)
Powered by Yahoo! Answers