Jump to content

JavaScript Problem.


Jacbey

Recommended Posts

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 :shy:

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.