show hide list boxes

Discussion in 'PHP' started by ciuchs, Mar 9, 2009.

  1. #1
    I am trying to hide or show an entire list box based on what the user selects and i am not entirely sure how to do it.
    i am wanting the user to select either school or city in the first list and based on the decision i want the following list box to appear.
    I am not sure if radio buttons would be better because i don't know anything about them.

    form name="school">
        <select name="type">
                <option value="school" selected="selected">School</option>
                <option value="city">City</option>
        </select>
        <select name="school">
        	<option value="North Central MO College" selected="selected">North Central MO College</option>
        </select>
        <select name="city">
       	  <option value="Trenton" selected="selected" >Trenton</option>
      </select>
    
    </form>
    PHP:
    thanks
     
    ciuchs, Mar 9, 2009 IP
  2. shubhamjain1

    shubhamjain1 Peon

    Messages:
    75
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not Tested!!

    <form name="school">
        <select name="type">
                <option> ---- </option>
                <option value="school" onclick="document.getElementById('City').disabled=true;document.getElementById('school').disabled=false;">School</option>
                <option value="city" onClick="document.getElementById('school').disabled=true;document.getElementById('city').disabled=false;">City</option>
        </select>
        <select name="school" id="school">
            <option value="North Central MO College" selected="selected">North Central MO College</option>
        </select>
        <select name="city" id="city">
          <option value="Trenton" selected="selected" >Trenton</option>
      </select>
    
    </form>
    
    Code (markup):
     
    shubhamjain1, Mar 10, 2009 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    To hide things, wrap them in divs with style display inline and when hiding, change inlink to none.

    Peace,
     
    Barti1987, Mar 10, 2009 IP
  4. ciuchs

    ciuchs Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks i used the div tags. the thought had never crossed my mind.
    again thanks for the help
     
    ciuchs, Mar 10, 2009 IP
  5. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #5
    That is a javascript issue and php isn't going to hide a select box after you selected something unless they press the SUBMIT button and the server gets a chance to process the form. Otherwise i would stick with JavaScript and not php.
     
    exodus, Mar 10, 2009 IP