View Single Post
  #2 (permalink)  
Old April 26th, 2007, 06:03 AM
annienell annienell is offline
Authorized User
 
Join Date: Oct 2006
Location: Yerevan, , Armenia.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
If I understand you right, this code will work for you.

------------------------------------------------------

<html>
<script>
test0 = "";
test1 = "test string 1";
test2 = "test string 2";
function setBlurb() {
var otionValue = document.form.blurbselect.value;
if (otionValue == "0") {
  document.form.textarea.value = test0;
} else if (otionValue == "1")
  document.form.textarea.value = test1;
  else if (otionValue == "2")
  document.form.textarea.value = test2;
};
</script>
<body>
<form name = 'form'>
<select name="blurbselect" onChange = "setBlurb();">
  <option value="0" ></option>
  <option value="1" >Test1</option>
  <option value="2" >Test2</option>
  <textarea name = "textarea" value = ""></textarea>
</select>
<form>
</body>

</html>
------------------------------------------------------

Guess switch operator will work faster than if-else-if for long list of options.

Best
Reply With Quote