View Single Post
Old 03-14-2013, 08:26 PM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,556
Thanks: 62
Thanked 4,055 Times in 4,024 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Well, you didn't say what the name of your "ID" field is, in the DB table.

So I have just called it ID. If it is something else, just change then names as shown in red.
Code:
<%@LANGUAGE="VBSCRIPT"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search for Landmarks</title>
<style type="text/css">
body,td,th {
	color: #0FF;
}
body {
	background-color: #000;
}
.Fonts {
	font-family: Trebuchet MS, Arial, Helvetica, sans-serif;
}
.Fonts2 {
	color: #FFF;
}
</style>
</head>

<body class="Fonts">
<h2>Landmark Search
</h2>
<p class="Fonts2">Landmark Name:</p>
<form name="form1" method="get" action="LandmarkInfo.asp">
  <p>
    <select name="Landname">
      <option value="">--choose one--</option>
<%
<!--#include file="Connections/Landmarks.asp" -->
<%
Set conn = Server.CreateObject ("ADODB.Connection")
conn.Open MM_Landmarks_STRING
SQL = "SELECT ID, LandName FROM dbo.tblLandmark ORDER BY LandName ASC" 

Set RS = conn.Execute( SQL )

Do Until RS.EOF
    id = RS("ID")
    name = RS("LandName")
%>
      <option value="<%=id & "$$" & name%>"><%=name%></option>
<%
    RS.MoveNext()
Loop
RS.Close
Conn.Close
%>
    </select>
  </p>
  <p>
    <input type="submit" />
    <input type="reset" name="Reset" id="Reset" value="Reset" />
  </p>
</form>
</body>
</html>
Now, that means that when this page is submitted to your "LandmarkInfo.asp" page, you will be getting something like
Code:
    371$$Washington Monument
when you use code such as
Code:
    landmark = Request.QueryString("landname")
So you will want to separate the ID from the name using code something like this:
Code:
    parts = Split( Trim( Request("landname") ), "$$" )
    id = CLNG(parts(0))
    landmarke = parts(1)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote