Jacbey Posted May 26, 2011 Author Share Posted May 26, 2011 I commented it out because I was trying to make it work a different way. But uncommented and still not working. And I have changed the tags to match mine. =/ Quote Link to comment https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1220600 Share on other sites More sharing options...
Adam Posted May 26, 2011 Share Posted May 26, 2011 Change any references of "mySelect" within the JS to match the ID attributed to your <select> in question. Change any references of "mySelectOther" within the JS to match the ID attributed to the DIV containing the 'other' text input. Also your opening script tag is: <script src="jquery-1.6.1.min.js" type="text/javascript" charset="utf-8"> Change it to: <script type="text/javascript"> Edit Also remove: onchange='showfield(this)' Although that shouldn't make much difference, as the code within the head should overwrite it. Edit..edit You also haven't assigned the value of "other" to you other option: <option>Other...</option> Change it to: <option value="other">Other...</option> Quote Link to comment https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1220603 Share on other sites More sharing options...
Jacbey Posted May 26, 2011 Author Share Posted May 26, 2011 Ok, i've made those changes but it still doesn't work. Anyway, I'm going to go to bed now. I will continue this tomorrow. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1220617 Share on other sites More sharing options...
gizmola Posted May 26, 2011 Share Posted May 26, 2011 Currently your js has a syntax error you need to fix. Quote Link to comment https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1220814 Share on other sites More sharing options...
Jacbey Posted May 26, 2011 Author Share Posted May 26, 2011 What's the syntax error? Quote Link to comment https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1220875 Share on other sites More sharing options...
hemo-ali Posted May 28, 2011 Share Posted May 28, 2011 this is the best <script type="text/javascript" src="jquery.js"> </script> <script type="text/javascript"> window.onload = function() { var mySelect = document.getElementById('school2'); mySelect.onchange = function() { if (this.value == 'other') { document.getElementById('otherdiv').style.display = 'block'; } else { document.getElementById('otherdiv').style.display = 'none'; } } } </script> <select id="school2"> <option>1</option> <option>2</option> <option>other</option> </select> <div id="otherdiv" style="display: none;"> asd </div> Quote Link to comment https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1221518 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.