Jacbey Posted May 27, 2011 Share Posted May 27, 2011 Hi Guys, I have a problem with my javascript and was wondering if anyone could help out. I think it's a syntax problem but I can't figure out what. <script type="text/javascript" src="jquery-1.6.1.min.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> Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted May 27, 2011 Share Posted May 27, 2011 The description of your issue lacks the details we require to help you. Mind putting some effort into your post? The only thing I notice is the fact that your loading jQuery without knowing what it actually is / provides. Quote Link to comment Share on other sites More sharing options...
hemo-ali Posted May 28, 2011 Share Posted May 28, 2011 I think it will help <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 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.