Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problematic IF Statement possibly

Status
Not open for further replies.

iisman

Technical User
Mar 6, 2005
85
CA
Hello,

I have the following code - a drop-down list populated from DB. It submits the form to the same page. I want to have the drop-down menu write in select="selected" for the item that was chosen, but i can not get this to work! Can anyone see why this may be?

Code:
<form name="stats" method="post" action="voteadmin.asp?content=2">

<font class="contentred">&nbsp;&nbsp;Choose Poll:</font>
<%
set conn = server.createobject("adodb.connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("../../employeesurvey/vote/polls.mdb")

set objRS = server.createobject("adodb.recordset")
strsql = "SELECT * FROM Questions"
objRS.open strsql, conn, 2, 2

dim tur
tur = Request.Form("stat")
'response.write tur
%>

&nbsp;<select name="stat" class="inputbox" onChange="this.form.submit();">
<%
Do While Not objRS.EOF
%>
<option value="<%=objRS("ID")%>"

<%
if objRs("ID") = tur then
response.write("select=""selected""")

end if
%>

>

<%=objRS("question")%>
</option>
<%objRS.movenext%><% loop %>
</select>
<input type="hidden" name="showresults" value="45" />

</form>

I check the html source code that is output to the browser, and nothing in that response.write("select=""selected""") is being output ... which leads me to beleive that there is a problem with one of the variables of with the if statement.

I have checked the tur variable with a response.write, and it does return the numerical value that i have intended,l so I dont think that is the issue...

any other help/suggestions would be appreciated.

Thanks in advance.
 
Try this:
Code:
<option value="<%=objRS("ID")%>"

<%
if objRs("ID") = tur then
response.write("""&"selected"&""")

end if
%>

>

<%=objRS("question")%>

-DNG
 
>[tt]response.write("""&"selected"&""")[/tt]
If not particularly concerned with xhtml recommendation, it is this.
[tt] response.write(" " & "selected")[/tt]
again I let the space stood out as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top