Well Bob, I just trimmed my code to get a test asp page. Here please note
that the tblYear has YearId and Year field. I need to display the Year Value,
yet capture the YearId(ie. the selected one from the list box) in the
processing form using request object. This YearId will go the sql statement
in the processing form.This is the main issue to me ie. how to display one
field in the list box yet capture the corresponding ID from the form in the
processing asp page using request form object. Hope I could explain well.
Here is the code for the test page. Thanks. Regards,
<!-- #include file="connectio n.asp" -->
<!-- #include file="adovbs.in c" -->
<HTML>
<HEAD>
<META NAME="GENERATOR " Content="Micros oft Visual Studio 6.0">
</HEAD>
<center>
<h2>
<b>
<font size="5" color="navy">
TEST
</font>
</b>
</h2>
</center>
<BODY>
<%
Set RS_Year = Server.CreateOb ject("ADODB.Rec ordset")
strSQL3 = "SELECT YearId, Year FROM tblYear"
RS_Year.Open strSQL3, conn
%>
<form method=POST name="frm_maine ntry" action="mainent ry_process.asp"
onSubmit>
<div align="center">
<table border = "1" width="80%" height="1" cellspacing = "1">
<tr>
<td width="50%" align ="center" height="18"><fo nt face="Times New Roman"
size="3" color = "red">COUNT TOTAL OFFENSES</font></td>
<td width="50%" align="center" BGCOLOR="white" height="18"><fo nt
face="Times New Roman" size="1">
<input type="text" name="txt_Count TotalOffenses" size="57"
style="font-family: Times New Roman; font-size: 12pt"></font></td>
</tr>
<%'Response.End %>
<tr>
<td width="74%" align ="center" height="18"><fo nt face="Times New Roman"
size="3" color = "red">YEAR</font></td>
<td>
<SELECT NAME="lstYear" SIZE="1">
<% Do while not RS_Year.EOF
Response.Write "<Option Value='" & RS_Year("YEAR") & "'>"
Response.Write RS_Year("YEAR") & "</OPTION>"
RS_Year.MoveNex t
Loop
%>
<td>
<tr>
<%'Response.End %>
<tr>
<td width="100%" align="right" colspan = "2" height="27"><p> <input
type="submit" value="Submit" name="B3"></td>
</tr>
</table>
</div>
</form>
</BODY>
</HTML>
"Jack" wrote:
Thanks Bob for your help. I am going to do that. However, the reason I am using
RS_Year("YEAR") for the option value is that I want to display all the YEAR
values in the the list box on the form. However, instead of Year I need to
capture the value of the corresponding code of the YEAR. This code goes to
the sql statement in the processing asp page. Thanks.
Response.Write "<Option Value='" & RS_Year("YEARID ")& "'>"
"Bob Barrows [MVP]" wrote:
Jack wrote: Hi,
I have a asp form where one element is a list box which lists four
years starting from 2004. This list is drawn from a database table
which has YearID and Year as two fields as shown below:
YearID YEAR
1 2004
2 2005
3 2006
4 2007
PART OF ASP CODE IS:
<tr>
<td width="74%" align ="center" height="18"><fo nt face="Times New
Roman" size="3" color = "red">YEAR</font></td>
<td>
<SELECT NAME="lstYear" SIZE="1">
<% Do while not RS_Year.EOF
Response.Write "<Option Value='" & RS_Year("YEAR") & "'>"
Response.Write RS_Year("YEAR") & "</OPTION>"
RS_Year.MoveNex t
Loop
%>
<td>
<tr>
Now I want to capture the value of the YearCode instead of the
So why are you using RS_Year("YEAR") for the option value? Wouldn't it make
more sense to change it to:
Response.Write "<Option Value='" & RS_Year("YEARID ")& "'>"
Year field and store the year code value in the processing form to
process in a sql statement.
i.e. I am planning to use the Request.Form("l stYear") to capture the
value of the year code. However, Request.Form("l istYear") is showing
no value.
At what point in the process? After you submitted form containing the above
SELECT element?
Create a small test form that reproduces the problem and post the entire
code from that SMALL test form.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.