467,173 Members | 1,368 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,173 developers. It's quick & easy.

doubt regarding select box....urgent

doubt regarding select box....urgent
in the below code i am getting data from database..according to the condition..
i want the available data in database to get displayed in selectbox..

for ex...
in the code i am getting color=rs("color")according to the condtion if(shirt=name)
if i get red, blue as result the i want these two colors to be in selectbox..
if its three colors means i want those three colors to get displayed in selectbox..

how to do this

regards
meenu


<%
set con=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")

Con.Open "dsn=tshirt"

set rs=con.execute("select * from table1")
while not rs.eof
name=rs("name")

if(shirt=name)then
color1=rs("color")

%>
<select name="color">
<option value="<%=color1%>"><%=color1%></option>
<%
end if
rs.movenext
wend
%>
Jul 21 '06 #1
  • viewed: 2082
Share:
5 Replies
Put your <Select ..> Tag out side while loop. It should be like this..

<%
set con=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")

Con.Open "dsn=tshirt"

set rs=con.execute("select * from table1")
if Not(rs.eof and rs.bof) Then
response.write "<select name="color">"
while not rs.eof
name=rs("name")
if(shirt=name)then
color1=rs("color")
%>
<option value="<%=color1%>"><%=color1%></option>
<%
end if
rs.movenext
wend
response.write "</select>"
else
''''Do something that have no values
End if
%>
Jul 22 '06 #2
thanks for ur reply...
i tried that but the following error occurs...
in response.write

Microsoft VBScript compilation (0x800A0401)
Expected end of statement

response.write "<select name="color">"
-----------------------------^
Jul 22 '06 #3
hi cbaro..

i got it worked...
i have made a small change in the code...and it worked..
i have placed the select statement outside the while loop...thats what the change..
anyway thanks for ur suggection...
<%
set con=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")

Con.Open "dsn=tshirt"

set rs=con.execute("select * from table1")
%>
<select name="color">
<%
while not rs.eof
name=rs("name")

if(shirt=name)then
color1=rs("color")

%>

<option value="<%=color1%>"><%=color1%></option>
<%
end if
rs.movenext
wend
%>


with regards
meenu
Jul 22 '06 #4
iam_clint
Expert 1GB
Put your <Select ..> Tag out side while loop. It should be like this..

<%
set con=server.createobject("adodb.connection")
set rs=server.createobject("adodb.recordset")

Con.Open "dsn=tshirt"

set rs=con.execute("select * from table1")
if Not(rs.eof and rs.bof) Then
response.write "<select name="color">"
while not rs.eof
name=rs("name")
if(shirt=name)then
color1=rs("color")
%>
<option value="<%=color1%>"><%=color1%></option>
<%
end if
rs.movenext
wend
response.write "</select>"
else
''''Do something that have no values
End if
%>
response.write "<select name="color">"
this would never work :) take a look at it

quote<select name=quote color quote>quote
your ending your response.write after the second quote so color">" would still be there thats the unexpected end of statement problem..
Jul 26 '06 #5
ya i got it...
thanks for ur reply..
and i got it worked also..
see the above code posted my me...
Jul 26 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by ramil | last post: by
6 posts views Thread by Mikus Sleiners | last post: by
10 posts views Thread by Dhananjay | last post: by
122 posts views Thread by ivan | last post: by
1 post views Thread by jai80 | last post: by
8 posts views Thread by somenath | last post: by
7 posts views Thread by new to c | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.