Classic ASP DatabasesDiscuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other programmers’ questions, win occasional prizes given to our best members, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I have a problem selecting a value from a recordset. The code i have currently populates the select box but i would like to select a value depending on my other recordset.
Its actually an update procedure im doing, but i want to return a recordset in an editable format with select boxes.
<%
Set oRs=Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT DISTINCT manager FROM tblManager ORDER BY manager"
oRs.Open strSQL
Do while not oRs.EOF
if Request.Form("selmanager") = oRs("manager") then 'if this is the selected one then display as selected
Response.Write "<OPTION VALUE = '" & oRS ("manager") & "' SELECTED>"
Response.Write oRs("manager") & "</Option>"
oRs.MoveNext
else
Response.Write "<OPTION VALUE = '" & oRs ("manager") & "'>"
Response.Write oRs("manager") & "</Option>"
oRs.MoveNext
end if
loop
%>
this code fills my select box fine, but im strugling when i want to select a default value.
... because you take that ( oRs.MoveNext ) behind the condition ?
<%
Set oRs=Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT DISTINCT manager FROM tblManager ORDER BY manager"
oRs.Open strSQL
Do while not oRs.EOF
if Request.Form("selmanager") = oRs("manager") then 'if this is the selected one then display as selected
Response.Write "<OPTION VALUE = '" & oRS ("manager") & "' SELECTED>"
Response.Write oRs("manager") & "</Option>"
else
Response.Write "<OPTION VALUE = '" & oRs ("manager") & "'>"
Response.Write oRs("manager") & "</Option>"
end if