Onchange of the dropdown list, the textfield should display either "testing 3" or "testing 4" but nothing is happening.

<form action='submit.php' method='POST' name='form'>
    <select name='preset' onchange='preset(this);'>
       <option value='test1'>testing 1</option>
       <option value=test2'>testing 2</option>
   </select>

<input type='text' name='big[]' value='' />

</form>
function preset(ele) {

if(ele=="test1") {
  var action1 = "testing 3";
} else {
  var action1 = "testing 4";
}

  document.form."big[0]".value = action1;

}

Recommended Answers

ele will, as the name correctly suggests, be an element, not a string. To get it's value attribute, use ele.value .

Jump to Post

All 2 Replies

ele will, as the name correctly suggests, be an element, not a string. To get it's value attribute, use ele.value .

replace ur line 2 with

<select name='preset' onchange='preset(this.value);'>

and

line 9 with

document.form.big[0].value = action1;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.