Jump to content

Other Box.


Jacbey

Recommended Posts

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>

Link to comment
https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1220603
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/237406-other-box/page/2/#findComment-1221518
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.