JavaScript获取Select当前值写法:
var value = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
var text = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].text;
例子:
复制番号代番号次のように:
<スクリプト>
関数チェック() {
var select = document.getElementById("select").options[document.getElementById("select").options.selectedIndex].value;
アラート(選択);
}
</script>
<select name="select" id="select">
<option value="test1" selected="selected">テスト 1</option>
<option value="test2">テスト 2</option>
</選択>
<input type="button" value="我要试试" onclick="check()"/>