0

i want onchange of an option in the dropdown list to change the value of the textarea. I tried but it's not working.

<script type='text/javascript'>
function ChgBox(number) {


var thecontent = document.getElementById(number).innerHTML;
   document.getElementById(content).value = thecontent;	
	
}
</script>
echo "<div style='display:none;' id='2'>Type Image Url</div>";	
			 $thenum ="2";

<select>
  <option value='1' >Your comment on</option>
  <option value='3' >Your question on</option>
  <option value='2' onchange='ChgBox($thenum);'>Your image about</option>
  <option value='0' >Comparison</option>
</select>
<textarea name='content' id='content'></textarea>
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Graphix
0

You are confusing PHP with JavaScript. I think you want to change the content of the textarea, depending on what option is selected. I think you want something like this:

<script type='text/javascript'>
function ChgBox(number) {


   var thecontent = document.getElementById(number).innerHTML;
   document.getElementById('content').value = thecontent;	
	
}
</script>

<select onchange='ChgBox(this.value);'>
  <option value='1' >Your comment on</option>
  <option value='3' >Your question on</option>
  <option value='2'>Your image about</option>
  <option value='0' >Comparison</option>
</select>

... Some other stuff...

<textarea name='content' id='content'></textarea>

~G

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.