-1
我想在這裏執行的操作是根據組合框中選擇的選項加載圖片。但是,當我從頁面後,組合框中選擇「2011」重新載入選擇的選項2012 again..plz幫我.... THIS IS MY ASP代碼asp中的組合框更新
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><
<head><title>Sinhgad Alumni</title>
<script type="text/javascript"></script>
</head>
<link rel="stylesheet" type="text/css" href="theme/gallery.css">
<body>
<%dim conn,rs,alumniyear,rs2
Response.write(alumniyear)
Set conn=Server.createObject("ADODB.Connection")
Set rs=Server.createObject("ADODB.Recordset")
Set rs2 = server.createObject("ADODB.Recordset")
conn.open="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &Server.MapPath("alumni.mdb") & ""
rs.open "select * from alumni",conn
%>
<div id="maincontent">
<div class="show">
<form name="form1" method="post"action="gallery.asp">
<h2 style="font:20px SegoeUI, 'Segoe UI', arial, sans-serif;margin: 0 auto;width: 300px;">Pictures of alumni in year:
<select name="drpyear" style="margin: 0 auto;width: 150px;height: 30px;text-align: center" onChange="javascript: document.forms['form1'].submit()" >
<%while NOT rs.EOF%>
<option onclick="javascript: document.forms['form1']">
<%response.write(rs("alumniyear"))%>
</option>
<%rs.MoveNext%>
<%wend%>
</select>
</h2>
</form>
<ul id="gallery">
<%alumniyear=Request("drpyear")
rs2.open "select * from gallery where alumni='"&alumniyear&"'",conn
if rs.EOF then%>
<li><img height="200"width="200" src=<%response.write(rs2("link"))%>></li>
<%else%>
<%while NOT rs2.EOF%>
<li><img height="200"width="200" src=<%response.write(rs2("link"))%>></li>
<%rs.MoveNext
WEND
end if
conn.Close
Set conn =Nothing%>
</ul>
</div>`
謝謝你這麼多,果然奏效。 ..但你能解釋我的代碼.. **
@ user1720452代碼中的添加檢查發佈的請求值是否等於您的記錄「alumniyear」值。如果是,則設置「selected」在致敬的選項元素(http://www.w3schools.com/tags/att_option_selected.asp) – AardVark71
您好工作時,我從組合框中選擇一個選項。但是當頁面首次加載時。代碼<%request(「drpyear」)。count%>返回0,但項目被加載到組合框中。 – Vishal