Forum Moderators: open

Message Too Old, No Replies

Making keypress on select

         

orion_rus

12:00 pm on Jan 3, 2005 (gmt 0)

10+ Year Member



Hello world i have a select with countries. I need to make a function when i make a keypress. Selected would be option where 1 symbol of select was 1 symbol in a country. But i have value in each option is a countryid, it's integer. I can't compare values. I need to compare all what is between <option> and </option>. Anybody know what is the value of this string?

adni18

3:07 pm on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<script language="javascript">
<!--
function bluffVals(d)
{
alert(d.options[d.selectedIndex].innerHTML)
}
//-->
</script>
<select onKeyPress="bluffVals(this)">
<option value=0>UK</option>
<option value=1>France</option>
<option value=2>USA</option>
</select>

rocknbil

5:00 pm on Jan 3, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



onChange might be a better event handler for a select list. Same thing, just onChange="yourAction()".