javascript - How to unhide select tag HTML? -
i trying following in html , javascript:
i using select tag (html) hidden until user clicks on no. if user click on no, select options appears , if user select yes, select options disappear. function works great input , other tags, not select tag.
i did lot of research , found out display:none , select tag not work google chrome , ie, solutions given in jquery , asp.net. since still new of this, wondering if there solution using html , javascript?
code html:
<div id="divmetspec" class="fieldrow"> <div class="leftlabel labelwidth20"> <label for="">met spec upon return:</label> </div> <div class="leftfield"> <div class="formfield68"> <input id="rbmetspec" name="rbmetspec" type="radio" class="radiobuttonfield" alt="met spec" title="met spec" value="yes" onclick="javascript:kitfailure();" />yes <input id="rbmetspec1" name="rbmetspec" type="radio" class="radiobuttonfield" alt="met spec" title="met spec" value="no" onclick="javascript:kitfailure();" />no </div> </div> </div> <div id="kitfailure" style="display:none"> <p class="indent">to select multiple options - please hold down ctrl button select:</p> <div class="leftlabel labelwidth20"> <label for="txtkitfailure">specify failure:</label> </div> <div class="leftfield"> <div class="formfield40"> <select id="txtkitfailure" type="text" class="fieldrow" name="kitfailure" multiple size="5"> <option value="failure1">failure 1</option> <option value="failure2">failure 2</option> <option value="failure3">failure 3</option> <option value="failure4">failure 4</option> <option value="failure5">failure 5</option> <option value="failure6">failure 6</option> <option value="failure7">failure 7</option> <option value="failure8">failure 8</option> </select> </div> </div> </div>
code javascript:
function kitfailure() { if (document.getelementbyid('rbmetspec1').checked) { document.getelementbyid('kitfailure').style.display = 'none'; } else document.getelementbyid('kitfailure').style.display = 'block'; }
thank in advance help.
irene
it works in ie11 + emulations, ff, chrome, , safari windows. corrections:
type="text"
not valid attribute of select
use multiple="multiple"
alt
not valid attribute of input
Comments
Post a Comment