Other field required when selected in drop down

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Other field required when selected in drop down

    I am having trouble to get this other field for "dialer" to be required when the user selects other. Ideally I'd like this field hidden until they select other.

    The HTML:


    The javascript:


    Thanks in advance.

    #2
    PHP Code:
    function otherVisability(dialer)
    {
            if(
    dialer=='Other')
            {
                 
    document.getElementById('dialer_other').style.visibility 'visible';
            }
            else
            {
                
    document.getElementById('dialer_other').style.visibility 'hidden';
            }

    usage:
    PHP Code:
    <select name="dialer" onchange="otherVisability(this.value);"
    and style for other:
    PHP Code:
    <input name="dialer_other" style="visibility: hidden" type="text" id="dialer_other" value="" size="20"
    Last edited by something else; 03.01.12, 15:06.

    Comment


      #4
      try it like this:
      PHP Code:
      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:
      PHP Code:
      <select name="dialer" onchange="otherVisability();"
      and same style as before
      Last edited by something else; 03.01.12, 15:05. Reason: incorrect spelling

      Comment


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

        Comment


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

          I will edit both of the above posts either should work fine
          Last edited by something else; 03.01.12, 15:09.

          Comment

          Working...
          X