<style type="text/css">
form select {
display:none;
}
form select.active {
display:block;
}
</style>
<script type="text/javascript">
window.onload = function() {
var allElem = document.getElementsByName("sl");
for (i = 0; i < allElem.length; i++) {
allElem[i].addEventListener('change', toggleDisplay);
}
}
function toggleDisplay(e) {
var id = 's' + this.value;
var currentSelect = document.getElementsByClassName("active")[0];
if (currentSelect) {
currentSelect.className = "";
}
document.getElementById(id).className = "active";
}
</script>
</head><body>
<form action="check_a.php">
<h2><b>Source: </b></h2>
<input type="radio" name="sl" value="c">Central</input>
<input type="radio" name="sl" value="h">Eastern</input>
<input type="radio" name="sl" value="w">Western</input>
<select id="sc" name="sc">
<option value="1">1</option>
<option value="2">2</option>
</select>
<select id="sh">
<option value="3">3</option>
<option value="4">4</option>
</select>
<select id="sw">
<option value="5">5</option>
<option value="6">6</option>
</select>
<input type="submit" name="submit" value="submit"/>
</form></body></html>
有一個單選按鈕,其值顯示特定的選擇框,這是使用javascript完成的。 標記的值需要傳遞給php代碼。 如何將選定的選項值傳遞給php?將選擇的選項值從select傳遞到php
上述代碼將在提交表單時將所選選項傳遞給PHP。你有什麼特別的問題? – Jim