View Full Version : comment posting feature in my site

03-17-2012, 08:12 AM
I am trying to create a comments posting feature in my site using javascript
However everytime i click on submit it shows the comment posted for a second and then the comment dissapears. It does not retain the comment posted. Please help.

code is given below:

<script type="text/javascript">
function post(){


<form name="hello">
<div id="label"> </div>
<textarea name="posted"> </textarea>
<input type="submit" value="Submit" onclick="post()">

Philip M
03-17-2012, 09:26 AM
When you click on a submit button the page is refreshed, and reloaded once more. Change the type to "button". But I expect that you realise that only the writer of the comment can see it! If you want all you users to see the comments then you will require server-side scripting and a database.

All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

03-17-2012, 11:06 AM
function post(){

return false;

<form name="hello" action="" method="post" onsubmit="return post();">Add the red lines.

and take out the onclick

<input type="submit" value="Submit" >

The above should submit the <form> and abort the default action to send the form data to the action's url after your label has been filled.