Here are my codes and I don't know where I go wrong :
function OnSelectedIndexChange(){
var getDropDown = document.getElementById("myDropDownID");
var getDropDownSelectedItemValue = getDropDown.options[getDropDown.selectedIndex].text;
if(getDropDownSelectedItemValue == 'Yes'){
document.getElementById("myTextAreaID").style.display = 'block';
}
else{
document.getElementById("myTextAreaID").style.display = 'none';
}
}
Added jsfiddle link : jsfiddle.net/wy562fk8/1 but i am using blade templating, so you can't be able to see any output.
Might be the reason you are doing
var getDropDownSelectedItemValue = getDropDown.options[getDropDown.selectedIndex].text;
instead of
var getDropDownSelectedItemValue = getDropDown.options[getDropDown.selectedIndex].value;
use onchange
function.
document.getElementById("myDropDownID").onchange = function {
if(document.getElementById("myDropDownID").value == 'Yes'){
document.getElementById("myTextAreaID").style.display = 'block';
}
else{
document.getElementById("myTextAreaID").style.display = 'none';
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.