如何使用Javascript从下拉列表中获取以前选择的项目和当前选择的项目?我想,使用几个隐藏字段,并在其中存储以前和当前的值。当dropdownlist值改变时,将当前隐藏字段值复制到prev。隐藏字段值,然后用选中的下拉value.But替换当前的隐藏字段值我是jquery.So新手,我不知道如何在condition.Any上面工作,我知道Jquery的意思是回答我。
发布于 2013-04-05 17:42:37
对于当前选定的项目,这应该是可行的
var yourSelect = document.getElementById('id');
alert(yourSelect.options[yourSelect.selectedIndex].value)对于上一版本
<select name="test">
<option value="test1">test1</option>
<option value="test2">test2</option>
<option value="test3">test3</option>
<option value="test4">test4</option>
</select>(function () {
var previous;
$("select[name=test]").focus(function () {
// Store the current value on focus, before it changes
previous = this.value;
}).change(function() {
// Do soomething with the previous value after the change
document.getElementById("log").innerHTML = "<b>Previous: </b>"+previous;
previous = this.value;
});
})();发布于 2013-04-30 13:33:50
使用以下命令:
document.getElementById("ddlcountry").optionsdocument.getElementById("ddlcountry").selectedIndex.value
https://stackoverflow.com/questions/15830584
复制相似问题