提交表单后,我很难将选项设置为“已选中”。在提交表单时,我能够检索提交的值,但是无法保持“表单的状态”(是的......很容易在.net中完成但是我在经典的ASP上提起并且从未继续前进!)。< / p>
我的阿贾克斯&amp; jquery技能非常有限,我一直在寻找类似的例子。我可以在购买选择列表中选择选项值,但是我无法在租赁列表中设置选项值,因为它是由ajax呈现的。
任何帮助表示感谢.... Harj
我的代码
<%
strDept = request("strDept")
strPrice = request("price")
if strDept = "Rent" then
strRentSelected = " selected "
strBuySelected = ""
else
strRentSelected = ""
strBuySelected = " selected "
end if
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(function(){
$("#dept").change(function() {
$('select[name="price"]').removeAttr("name").hide();
$("#" + $(this).val()).show().attr("name", "price");
});
});
//]]>
</script>
</head>
<body>
<form action="main.asp" method="post">
<select id="dept" name="strDept">
<option value="Buy" <%=strBuySelected %>>Buy</option>
<option value="Rent" <%=strRentSelected %>>Rent</option>
</select>
<select id="Buy" name="price" class="price">
<option value="5000">5,000</option>
<option value="25000">25,000</option>
<option value="50000">50,000</option>
<option value="100000">100,000</option>
<option value="150000">150,000</option>
<option value="200000">200,000</option>
<option value="250000">250,000</option>
<option value="500000">500,000</option>
<option value="1000000">1,000,000</option>
</select>
<select id="Rent" style="display:none" class="price">
<option value="0">0 pcm</option>
<option value="200">200 pcm</option>
<option value="300">300 pcm</option>
<option value="400">400 pcm</option>
<option value="500">500 pcm</option>
<option value="600">600 pcm</option>
<option value="700">700 pcm</option>
<option value="1000">1000 pcm</option>
<option value="5000">5000 pcm</option>
</select>
<br><br>
<input type="Submit" name="strAction" value="Submit">
</form>
</body>
</html>