For some reason the code below it is not working correctly. Unless I\'m being quite stupid with my JavaScript I can\'t see what\'s going wrong besides the onclick events not
An answer with JS only, not jQuery:
onclick event in option tag is just recognized by Firefox. If you need a solution that works on all browsers such as IE or Chrome you can use onchange event on your "Select" element.
HTML :
JS defined in the html head section as script:
function showHideOther(value){
alert(value);
if (value==='other'){
document.getElementById('other').value = "";
document.getElementById('other').style.display = 'block';
document.getElementById('otherBR').style.display = 'block';
}
else{
document.getElementById('other').style.display = 'none';
document.getElementById('otherBR').style.display = 'none';
}
}
JSFiddle sample working fine: http://jsfiddle.net/amontellano/gLML3/14/
I hope it helps.