Use Jquery .change()
Try this :
<select id="p1" name="p1">
<option value="ok">Ok</option>
<option value="closed">Closed</option>
<option value="ko">KO</option>
</select>
Jquery:
$('select#p1').change(function(){
if(this.value == "ok"){
//-- Your Code IF someone select "OK"
}
else if(this.value == "closed"){
//-- Your Code IF someone select "Closed"
}
else if(this.value == "ko"){
//-- Your Code IF someone select "KO"
}
});
According to OP question (run a script on the page only when the value is changed from 'Ko to Ok'):
You can use Custom Data Attributes for storing the previously selected option value.
Try this:
$("select#p1").one('focus', function () {
$(this).prop('data-previous', $('select#p1').val());
}).change(function(){
if($(this).prop('data-previous') == "ko" && $(this).val() == "ok"){
alert('Change');
}
$(this).prop('data-previous', $(this).val());
});
Working Example
Above code - We set data attribute data-previous when the select drop-down focused once. and than we bind the .change() event with select, so when options changed occurred we can check the previous selected and currently selected value and perform our operation (in the above example i am doing alert()).