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