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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass a code from a list box to a processing asp form

Status
Not open for further replies.

jck1

Programmer
Feb 22, 2006
8
US
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"><font 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.MoveNext
Loop
%>
<td>
<tr>

Now I want to capture the value of the YearCode instead of the Year field that the user chooses from the list box 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("lstYear") to capture the value of the year code. However, Request.Form("listYear") is showing no value.
I would appreciate any help or any article link for handling this problem. Thank in advance.
 
i.e. I am planning to use the Request.Form("lstYear") to capture the value of the year code. However, Request.Form("listYear") is showing no value.
is that a typo in your post? otherwise there is your problem.


Chris.

Indifference will be the downfall of mankind, but who cares?
Woo Hoo! the cobblers kids get new shoes.
People Counting Systems

So long, and thanks for all the fish.
 
Sorry, it was indeed a typo. Any other thoughts about where the above code is wrong. Thanks.
 
Code:
<% 
Do while not RS_Year.EOF
    Response.Write "<Option Value='" & RS_Year("CODE")& "'>" & RS_Year("YEAR") & "</OPTION>" & vbcrlf
    RS_Year.MoveNext
Loop
%>


[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never inside the 'loop' " - DreX 2005
 
replace rs_year("code") with rs_year("yearID")... i didn't see the field name listings in your sample data above.

[thumbsup2]DreX
aKa - Robert
if all else fails, light it on fire and do the happy dance!
" I always think outside the 'box', because I'm never inside the 'loop' " - DreX 2005
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top