Reputation: 167
I am trying to change text in a text field based on the selection in a drop down list. This is being done in javascript. The following code is what I am trying:
var myList = document.getElementById("000");
var myVariable= document.getElementById("111");
var myListValue = myList.options[myList.selectedIndex].value ;
if(myListValue == 1){
myVariable.text = "Hello";
}
I have tried comparing with both the value of the drop down list selected value and text... Can anyone tell me what I am doing wrong?
Upvotes: 0
Views: 63
Reputation: 2083
to assign a 'value' to a text input, you need to set the 'value' instead of 'text' property:
if(myListValue == 1){
myVariable.value = "Hello";
}
see this JSFiddle
Upvotes: 0