SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Disable Radio button with Select Box

    I'm using the following code, and for some reason i can't get it to work. I want it so that when the user Selects South Africa, it disables Flight Option 2. Can someone please help me, I don't see where I'm going wrong...

    Header:
    <SCRIPT LANGUAGE="JavaScript">

    function Disab(val) {
    if(val=="Australia")
    {document.form1.flight_options[0].disabled=false;document.form1.flight_options[1].disabled=false}
    if(val=="New Zealand")
    {document.form1.flight_options[0].disabled=false;document.form1.flight_options[1].disabled=false}
    if(val=="South Africa")
    {document.form1.flight_options[0].disabled=false;document.form1.flight_options[1].disabled=true}
    }

    </SCRIPT>

    Form:
    <select name="country" onChange="Disab(this.value)">
    <option value="Australia">Australia</option>
    <option value="New Zealand">New Zealand</option>
    <option value="South Africa">South Africa</option>
    </select>

    <input type="radio" name="flight_option" value="Option 1" />Flight Option 1

    <input type="radio" name="flight_option" value="Option 2" />Flight Option 2

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    the flight_option / flight_options need to be the same
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •