javascript - Select latest selected value of a dropdown -
is there way select latest user's selected value of dropdown?
eg:
<select id="data" name="data" class="data" multiple="multiple"> <option value="100">foo</option> <option value="101">bar</option> <option value="102">bat</option> <option value="103">baz</option> </select> if use bellow example, last index, it's not want.
var latest_value = $("option:selected:last",this).val(); what want like: if select "bar", 101, if select "foo" 101 instead of 100.
obs: examples considering user selecting multiple values, not one.
use simple js code:
var is_now_selected = document.getelementbyid('data').value; // or jquery var is_now_selected = $('#data').val() maybe don't know option-value accually value of select. if click <option value="something"> inside <select name="select_me">, select have value of selected option - in case - "select_me".
Comments
Post a Comment