...

View Full Version : SelectedIndex Help With Dropdown



kraftomatic
01-22-2009, 06:17 PM
Hey Guys,

I've got a small issue and it has to be something simple I'm missing. I've got the following list of 10 links that work just fine:



<a href="javascript:showGroup('05', '.05')">link name</a>
<a href="javascript:showGroup('10', '.10')">link name</a>

...

The values inside the showGroup function are all that change and I'm trying to move them into a dropdown. However I can't get it work correctly. This is what I currently have:




<select name="showGroup_dropdown" onChange="document.getElementById('selectedIndex.value')">
<option value="javascript:showGroup('05', '.05')">Option 1<option>
<option value="javascript:showGroup('10', '.10')">Option 2<option>
...
</select>

I want the select statement to pull the value from the option value selected, and then run the function that goes with it. However my code inside the OnChange event is incorrect. I can hardcode a single value and have it work:


onChange="showGroup('05', '.05')"

But obviously I need to pull the correct value from the option selected in the dropdown.

Does anyone have any advice? Any suggestions would be appreciated.

Thanks.

jmrker
01-22-2009, 08:22 PM
Assuming no errors elsewhere, try this:


<select name="showGroup_dropdown" onChange="this.value">
<option value="javascript:showGroup('05', '.05')">Option 1<option>
<option value="javascript:showGroup('10', '.10')">Option 2<option>
...
</select>

Code not tested ...

Philip M
01-22-2009, 08:59 PM
<select name = "showGroup_dropdown" id="showGroup_dropdown" onchange="getValue()">
<option value="javascript:showGroup('05', '.05')">Option 1< /option>
<option value="javascript:showGroup('10', '.10')">Option 2< /option>
</select>

<script type = "text/javascript">
function getValue() {
var group = document.getElementById("showGroup_dropdown").value;
alert (group);
}
</script>

Code tested ...... :D



I have nothing but confidence in you. And very little of that.
Groucho Marx (1890 - 1977)

kraftomatic
01-23-2009, 04:17 PM
That helps a bunch, thanks guys.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum