开发者

Javascript & Combobox - Send the value of an item focused

开发者 https://www.devze.com 2023-01-27 05:48 出处:网络
I have a combobox with some values : <select id=\"combo\" name=\"my_combo\" size=\"0\" onchange=\"myFunction(this.getFocusedValue)\">

I have a combobox with some values :

<select id="combo" name="my_combo" size="0" onchange="myFunction(this.getFocusedValue)"> 
    <option value="1">1 Me开发者_开发问答se</option>
    <option value="2">2 Mesi</option>
    <option value="3">3 Mesi</option>
    <option value="4">4 Mesi</option>
</select>

I want to translate that this.getFocusedValue on a real JavaScript code :)

How can I do this? Would be nice if this works on all browser (else i can use Jquery).

Thanks

SOLUTION

<select id="combo" name="my_combo" size="0" onchange="changeArticle(this.options[this.selectedIndex].value)">


this.selectedIndex;

Edit:

index = this.selectedIndex;
return this.options[index].value;
0

精彩评论

暂无评论...
验证码 换一张
取 消