forms - show other field if other selected in menu with javascript -
i trying display field capture users input if select other in select menu. code below id otherjobtype not unhiding when select other in menu. can spot have gone wrong? in advance.
<style type="text/css"> #otherjobtype { display:none; } </style> <script type="text/javascript"> function jobtype(value){ if (value == 'other') { document.getelementbyid('otherjobtype').style.display = 'block'; } else { document.getelementbyid('otherjobtype').style.display = 'none'; } } </script> <select id="jobtype" name="jobtype" onchange="jobtype(this.value);"> <option value="option 1" selected>option 1</option> <option value="other">other</option> </select> <input name="otherjobtype" id="otherjobtype" type="text" size="50" value="please specify job type" onblur="if (this.value=='') { this.value='please specify job type' }" onclick="if (this.value=='please specify job type') { this.value='' }" />
i fixed in end renaming function "workjobtype" leaving id , name on select menu "jobtype". if either of these same function name didn't work reason. love hear if explain why didn't work?
it's stange because worked fine in jsfiddle musa posted on page has lots more going on wasn't working until change function name using.
Comments
Post a Comment