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
https://forums.phpfreaks.com/topic/237601-javascript-problem/
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
https://forums.phpfreaks.com/topic/237601-javascript-problem/#findComment-1221520
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.