Create a dropdown list and make another unselectable

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.

thanks,
john
jlcannonAsked:
Who is Participating?
 
Ashley BryantConnect With a Mentor Senior Software EngineerCommented:
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">
     <option>...</option>
</select>

<select id="thing2" name="thing2" disabled>
     <option>...</option>
</select>

Open in new window

0
 
iandianConnect With a Mentor Commented:
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"'>
<option></option>
...
</select>

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

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.
0
 
jlcannonAuthor Commented:
you both have answered my 2 part question so I split the points. thank you so much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.