ASP中SELECT下拉菜單同時(shí)獲取VALUE和TEXT值的實(shí)現(xiàn)代碼
在1個(gè)注冊(cè)頁(yè)面1.asp ,先選擇鎮(zhèn),如下代碼:
<form action="reguser2.asp" method="post" name="form1" onSubmit="return checksumit();"> <table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <td>所在鎮(zhèn): <% sql="select * from zhen" set rs=server.createobject("adodb.recordset") rs.open sql,conn,3,2 %> <select name="zhen" id="zhen"> <option value=-1>選擇鎮(zhèn)</option> <% if rs.eof and rs.bof then response.Write("<option value=-1>沒(méi)有鎮(zhèn)</option>") else do while not rs.eof %> <option value="<%=rs("z_id")%>"><%=rs("z_name")%></option> //這里value 和 text 的值 在數(shù)據(jù)庫(kù)中獲得 ,但變量"zhen" 只能獲得value的值...如何獲得選中的 text值呢? <% rs.movenext loop end if%> </select></td> </tr> <tr align="center"> <td><input type="submit" name="Submit" value="下一步" onclick="Javascript:callvalue()"></td> //第三步,傳遞到下一頁(yè)按鈕這里增加 onclick取得值 </tr> </table> <input type="hidden" name ="sendvalue" /> //第一步,這里增加一個(gè)hidden的input控件 <script language="JavaScript"> //第二步,這里寫(xiě)一個(gè)獲得text值的函數(shù) function callvalue() { sendvalue = document.form1.zhen.item(document.form1.zhen.selectedIndex).text; //alert(sendvalue); document.form1.sendvalue.value = sendvalue; form1.submit(); } </script>
最后,在另外一個(gè)頁(yè)面 2.asp 里面直接取選定的text值 request.Form("sendvalue")
這樣,可以不頻繁讀取數(shù)據(jù)庫(kù)取得值
相關(guān)文章
ASP同一站點(diǎn)下gb2312和utf-8頁(yè)面?zhèn)鬟f參數(shù)亂碼的終極解決方法
要解決ASP同一站點(diǎn)下gb2312和utf-8頁(yè)面?zhèn)鬟f參數(shù)亂碼問(wèn)題,只需嚴(yán)格做到以下4點(diǎn)即可。2010-12-12asp實(shí)現(xiàn)生成由數(shù)字,大寫(xiě)字母,小寫(xiě)字母指定位數(shù)的隨機(jī)數(shù)
asp實(shí)現(xiàn)生成由數(shù)字,大寫(xiě)字母,小寫(xiě)字母指定位數(shù)的隨機(jī)數(shù)...2007-08-08asp 批量刪除選中的多條記錄的實(shí)現(xiàn)代碼
如果需要?jiǎng)h除記錄,一條一條的刪比較耗時(shí),所以批量刪除記錄是個(gè)不錯(cuò)的功能,原理就是利用asp數(shù)組來(lái)實(shí)現(xiàn)。2011-06-06ASP中保留小數(shù)點(diǎn)后兩位數(shù)的方法(使用FormatNumber)
這篇文章主要介紹了ASP中保留小數(shù)點(diǎn)后兩位數(shù)的方法,使用FormatNumber函數(shù)實(shí)現(xiàn),需要的朋友可以參考下2014-06-06利用 cache 做對(duì)比靜態(tài)頁(yè)的網(wǎng)頁(yè)技術(shù)
利用 cache 做對(duì)比靜態(tài)頁(yè)的網(wǎng)頁(yè)技術(shù)...2007-10-10ASP類(lèi)型網(wǎng)站結(jié)合動(dòng)網(wǎng)論壇會(huì)員的方法
ASP類(lèi)型網(wǎng)站結(jié)合動(dòng)網(wǎng)論壇會(huì)員的方法...2007-11-11asp實(shí)現(xiàn)樹(shù)型結(jié)構(gòu)
asp實(shí)現(xiàn)樹(shù)型結(jié)構(gòu)...2007-03-03