Q:

get the value of option tag based on text in HTML SELECT

I have one question. I have one scenario where i need to get value of option tag based on option text.
<select>
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>

here imagine i want to get the value "2" based on the supplied text "two".
how can we achieve that?

A:

You can try something like this javascript 
Say this what you provided :
<select id="test">
<option value="0">zero</option>
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>

var e = document.getElementById("test");
var actualValue= e.options[e.selectedIndex].value;

