日期:2014-05-16  浏览次数:20354 次

救大侠们帮助!!
例:
<select name="bjbh" id=bjbh>
<option value="0">三一班</option>
....
....
....
</select>

我想把所选中的值(例:value="0")以及“(例:三一班)”都存到数据库中。如何实现?

------解决方案--------------------
增加一个隐藏文本框,后台分别接收下拉列表和隐藏文本框的值。
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload = function() {
    var oSelect = document.getElementById('bjbh');
    var oHidden = document.getElementById('txt_bjbh');
    oHidden.value = oSelect.options[oSelect.selectedIndex].innerHTML;
    oSelect.onchange = function() {
        oHidden.value = this.options[this.selectedIndex].innerHTML;
    }
}
</script>
</head>

<body>
<form>
    <select id="bjbh" name="bjbh">
        <option value="0">三一班</option>
        <option value="1">三二班</option>
    </select>
    <input type="hidden" name="txt_bjbh" id="txt_bjbh" />
</form>
</body>
</html>