Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question regarding dropdowns

Status
Not open for further replies.

Linkan

Programmer
Feb 7, 2001
44
0
0
SE
Hello, I have two dropdowns, they are not dependent but they both pull data from a DB.
The first one is -CARS- and the second is -COLOR-. I want to make sure that if no -CARS- is selected -COLOR- should jump back to -COLOR-. Value for both -CARS- and -COLOR- is "-".
This means I dont want to post -CARS- "GREEN".

Thanks for a great forum.

//Jonas
 
Try this...

Code:
function doThis() {
  var cars = eval("document.forms[0].wl_cars");
  var car = cars.value;
  var colors = eval("document.forms[0].wl_colors");
  var color = colors.options[colors.selectedIndex].value;
  if (car == "-" || color == "-") {
    cars.options[0].selected = true;
    colors.options[0].selected = true;
  }
}
Hope this helps,
Jessica
[ponytails2]
 
Can do this also:

function tryThis()
{
if(cars.options[colors.selectedIndex].value == "-")
{
colors.options[0].selected = true;
}
}

And call this method on onChange of Cars Drop Down.

Harsh [sunshine]
 
***
Very good, thanks for your promt answer.
Works like a charm.

//Linkan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top