Create a dropdown list and make another unselectable

Posted on 2009-12-17
Last Modified: 2012-05-08
Hello all,
I am hoping you awesome folks can help me out. First off I need to make 2 dropdown select boxes on my form but there is like 60 selections for each one so I was wondering is there a quicker way to do it that typing one at a time like <option>thisone</option> . I have them all listed in excel is there a way I could just select the whole column and paste it somehow and it automaticly knows to make them options in the slelect box? and then 2nd I meantioned having 2 of those dropdown boxes. well they will both have the same exactoptions but one will be for gas and one will be for deisle so what i want is to make it where if you make a selection on the gas one, the deisel one cannot be used or it wont let you select from it and vice versa. I hope this is not too confusing.

Question by:jlcannon
    LVL 12

    Accepted Solution

    How often will the options in your dropdowns change?  If it's going to be fairly often, you should consider reading the options from a database instead.  If they aren't going to change very often, and you're going to hard-code them, you are basically stuck keying them in.  Copy/paste the list into your code, then copy/paste the <option> tags around them.  It really shouldn't take long.

    To disable one drop-down and then enable it once the first one is changed, you would do something like this:

    <select onchange="var thing2=document.getelementybyId('thing2');thing2.disabled=false;" id="thing1" name="thing1">
    <select id="thing2" name="thing2" disabled>

    Open in new window

    LVL 6

    Assisted Solution

    you can put an event on 1 select box (e.g. onchange) so when a value is selected the event fires. In this event you can disable the other selectbox

    <select id="gas" onchange="javascript:document.getElementById("deisle ").disabled="disabled"'>

    <select id="deisle " onchange='javascript:document.getElementById("gas").disabled="disabled"'>

    As fot he getting options from excel, you cant do this simple in a texeditor, but if you are using some program to create the webpage you might, depending on the program.

    Author Closing Comment

    you both have answered my 2 part question so I split the points. thank you so much.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Building “do-it-yourself” web sites has become an epidemic. There are so many blogs, web sites and even books that "teach" you how to build your web site in a few extremely simple and easy steps. Building a web site has become easier than boiling an…
    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now