Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7

Thread: 2 lists

  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    2 lists

    Hello,
    I have two dropdown lists on a form. How can I make it so the user must select from list a or list b but not both?

    Thanks for any help.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Do the select tags have size > 1? and select multiple?

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi glenngv,
    List A consists of Canadian Provinces, and List B consists of States. I want the applicant to choose only one state or one province. They must make a selection from one list only.
    Thanks for your help, I appreciate it.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    <select name="province" size="5" onchange="document.yourformname.state.selectedIndex=-1">

    </select>
    <select name="state" size="5" onchange="document.yourformname.province.selectedIndex=-1">

    </select>

    change the size to anything greater than 1 and yourformname to your appropriate form name


    Originally posted by Beginner
    hi glenngv,
    List A consists of Canadian Provinces, and List B consists of States. I want the applicant to choose only one state or one province. They must make a selection from one list only.
    Thanks for your help, I appreciate it.

  • #5
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hello,
    Thanks so much, it's exactly what I needed.

  • #6
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Greetings,
    Is it possible to ensure that a selection has been made from one list or the other, via an 'alert' if both are left unselected?
    Thanks for any help.

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    function check(){
    frm = document.yourformname;
    if (frm.province.selectedIndex==-1 && frm.state.selectedIndex==-1){
    alert("You must choose a province or a state.");
    return false;
    }
    //other checking here

    return true;
    }

    <form onsubmit="return check()" ...>

    Originally posted by Beginner
    Greetings,
    Is it possible to ensure that a selection has been made from one list or the other, via an 'alert' if both are left unselected?
    Thanks for any help.


  •  

    Posting Permissions

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