I want to create a picklist from fields in a database. The two db fields are Code and Pages, and both display the exact same information - the names of web pages under each column:
code | pages
----------------------
home | home
links | links
site info | site info
Depending on which option the user selects, then the user will be redirected to that page e.g. if links is clicked, then obviously they would go to the links page. At the moment, I've only got it working for two options: either click home and go to alpha, or click something else and go to beta. I want it so that every option leads to a different page. I think that I may need to just expand the if...else bit of my code, but I'm not entirely sure as to how I could do this. I've tried 'case' as well and had no luck.
Here's my code (what is written in on alpha.htm and beta.htm is irrelevant):
<%
strconn = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database/ambvibdb.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
dim locpage
locpage = request.form("gotopage")
If locpage <>"" then
If locpage = "Home" then
Response.redirect("alpha.htm")
else
Response.redirect("beta.htm")
end if
end if
'connect to database
SQLQuery = "Select * from Pages where Pages = '"
sqlquery = sqlquery & loccust & "'"
Set RSPage = Conn.Execute(SQLQuery)%>
<html>
<head>
</head>
<body>
<form action="pickithome.asp" onSubmit="return isReady(this)" METHOD=post name="form1" >
<table>
<TD width="1"> <select size=1 name="gotopage">
<%
SQLQuery = "Select * from Pages"
Set RSPage = Conn.Execute(SQLQuery)
Do While Not RSPage.Eof
if rspage("Code") = "Home" then
response.write("<option value=" & RSPage("Code") & " selected>" & RSPage("Pages") & "</option>")
else
response.write("<option value=" & RSPage("Code") & ">" & RSPage("Pages") & "</option>")
end if
RSPage.Movenext
Loop
SET RSPage = NOTHING
SET Conn = NOTHING
%>
</select></TD>
<tr>
<td width = "118" height="50"><input TYPE="Submit" VALUE="submit" id=Submit1 name=Submit1></td>
<td width="1" height="50"><input TYPE="Reset" VALUE="Clear Details" id=Reset1 name=Reset1> </td>
</tr>
</table>
</form>
</body>
</html>
Can anyone alter this code to help me out?
code | pages
----------------------
home | home
links | links
site info | site info
Depending on which option the user selects, then the user will be redirected to that page e.g. if links is clicked, then obviously they would go to the links page. At the moment, I've only got it working for two options: either click home and go to alpha, or click something else and go to beta. I want it so that every option leads to a different page. I think that I may need to just expand the if...else bit of my code, but I'm not entirely sure as to how I could do this. I've tried 'case' as well and had no luck.
Here's my code (what is written in on alpha.htm and beta.htm is irrelevant):
<%
strconn = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("database/ambvibdb.mdb")
set conn = server.createobject("adodb.connection")
conn.open strconn
dim locpage
locpage = request.form("gotopage")
If locpage <>"" then
If locpage = "Home" then
Response.redirect("alpha.htm")
else
Response.redirect("beta.htm")
end if
end if
'connect to database
SQLQuery = "Select * from Pages where Pages = '"
sqlquery = sqlquery & loccust & "'"
Set RSPage = Conn.Execute(SQLQuery)%>
<html>
<head>
</head>
<body>
<form action="pickithome.asp" onSubmit="return isReady(this)" METHOD=post name="form1" >
<table>
<TD width="1"> <select size=1 name="gotopage">
<%
SQLQuery = "Select * from Pages"
Set RSPage = Conn.Execute(SQLQuery)
Do While Not RSPage.Eof
if rspage("Code") = "Home" then
response.write("<option value=" & RSPage("Code") & " selected>" & RSPage("Pages") & "</option>")
else
response.write("<option value=" & RSPage("Code") & ">" & RSPage("Pages") & "</option>")
end if
RSPage.Movenext
Loop
SET RSPage = NOTHING
SET Conn = NOTHING
%>
</select></TD>
<tr>
<td width = "118" height="50"><input TYPE="Submit" VALUE="submit" id=Submit1 name=Submit1></td>
<td width="1" height="50"><input TYPE="Reset" VALUE="Clear Details" id=Reset1 name=Reset1> </td>
</tr>
</table>
</form>
</body>
</html>
Can anyone alter this code to help me out?