問題:
我需要向后台傳遞表單里我選擇的select里面的值,那我應該怎么獲取里面的值呢?
解答:
<!doctype html>
<html >
<head>
<meta charset="UTF-8">
<title>拿到select里的值</title>
</head>
<body>
<form>
<select id="test1" onchange="check()">
<option value="check1">選擇1</opiton>
<option value="check2">選擇2</opiton>
<option value="check3">選擇3</opiton>
</select>
</form>
<script>
function check(){
var r = getElementById("test1").value;
alert(r);
}
</script>
<body>
</html>