Other field required when selected in drop down

Started on the old forum in December 2011 · view the original in the archive · old links redirect here

5 replies · 400 views · started 14 years ago · 1 min read

2 participants
something else Fellow · 2,296 posts #2
function otherVisability(dialer)
{
        if(dialer=='Other')
        {
             document.getElementById('dialer_other').style.visibility = 'visible';
        }
        else
        {
            document.getElementById('dialer_other').style.visibility = 'hidden';
        }
}

usage:

<select name="dialer" onchange="otherVisability(this.value);">

and style for other:

<input name="dialer_other" style="visibility: hidden" type="text" id="dialer_other" value="" size="20">
something else Fellow · 2,296 posts #4

try it like this:

function otherVisability()
{
        var dialer = document.getElementById('dialer').value;

        if(dialer=='Other')
        {
             document.getElementById('dialer_other').style.visibility = 'visible';
        }
        else
        {
             document.getElementById('dialer_other').style.visibility = 'hidden';
        }
} 

and usage:

<select name="dialer" onchange="otherVisability();">  

and same style as before

johnwboyd Junior · 12 posts #5

Still doesn't work. 🙁 Are you testing before posting?

something else Fellow · 2,296 posts #6

sorry "dialer-other" is spelt incorrectly it should be "dialer_other"

I will edit both of the above posts either should work fine 🙂

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close