• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 644
  • Last Modified:

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
0
jlcannon
Asked:
jlcannon
2 Solutions
 
Ashley BryantSenior 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
 
iandianCommented:
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now