Jump to content

text area not updating properly


zain123

Recommended Posts

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...

Link to comment
Share on other sites

<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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.