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
https://forums.phpfreaks.com/topic/146114-text-area-not-updating-properly/
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.

Archived

This topic is now archived and is closed to further replies.

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