zain123 Posted February 20, 2009 Share Posted February 20, 2009 I have the following code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Form</title> <script language="javascript"> function replaceText() { document.form1.textarea1.value = "DMC "; } </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <textarea name="textarea1" cols="90" rows="5" id="textarea1" style="width:380px;height:200px;">3/3/2008 His really happy withe the current business is going well. Therefore unlikely to look this year.</textarea> <input type="submit" name="button" id="button" value="Decision Maker Conversion" onclick="replaceText()"/> </form> </body> </html> When the submit button is clicked, the text area updates with DMC for only a second and then it goes back to the original text.. not sure whats happening? Anyone have any idea? thanks in advance... Quote Link to comment Share on other sites More sharing options...
gethinw Posted February 20, 2009 Share Posted February 20, 2009 <input type="submit" name="button" id="button" value="Decision Maker Conversion" onclick="replaceText();return false;"/> When you click the button it is reloading the page (ie the form is submitting itself, and as you haven't declared an action it uses the current page as a default action). By adding "return false" to the onclick it means that the submit action isn't carried out, just the onclick action. Quote Link to comment Share on other sites More sharing options...
zain123 Posted February 20, 2009 Author Share Posted February 20, 2009 aaaah thanks for that mate Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.