Follow Slashdot blog updates by subscribing to our blog RSS feed

 



Forgot your password?
typodupeerror
Note: You can take 10% off all Slashdot Deals with coupon code "slashdot10off." ×
The Internet

Journal OctaneZ's Journal: Need some javascript help 1

Okay, I need some web help! Googling for javascript help yields tens of thousands of seemingly unhelpful tutorials and guides. I have a webform with 3 select boxes:

[Select #1] [Select #2] [Select #3]

I would like to "chain" the boxes, such that values for boxes #2 and #3 are selected based on the value of the option selected in box #1; for those curious the first box is the maximum depth the Spray glider should dive to, the second box, is the maximum glide time, and the third field is the number of points it should average when telemetering data back to shore. I've tried a b8unch of onChange's; and tried hard to make selectedIndex work, but there must be someway that uses the value of the option rather than it's place in the index right? There are a couple hundred options in the menus. Any ideas?

This discussion has been archived. No new comments can be posted.

Need some javascript help

Comments Filter:
  • It's not going to be exactly right (I'm a bit rusty), but it might help you out some.

    tar is the list box which is going to be changed
    appropriateValue is the the value which needs to be selected in tar

    Here's a loop that uses the values of the options in a drop down list as a comparison and assigns selected Index of the last matching value.

    var selIndex = -1;
    for(var i = 0; i tar.length; i++)
    {
    if(tar.options[i].value == appropriateValue)
    {
    selIndex = i;
    }
    }
    tar.selectedIndex = selIndex;

    Hope this is somewhat helpful.

"Floggings will continue until morale improves." -- anonymous flyer being distributed at Exxon USA

Working...