473,657 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass a code of a list box to a processing form

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 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.
I would appreciate any help or any article link for handling this problem.
Thank in advance.


Mar 1 '06 #1
15 1965
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.
Mar 2 '06 #2
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.

Mar 2 '06 #3
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.

Mar 2 '06 #4
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.


The Value is not displayed, the text is. Try it.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Mar 2 '06 #5
I'm curious.

Since each year only happens once, why do you have a yearID column? I'm not
even really sure why you have a year table to begin with.

Unless you know something......

Bob Lehmann

"Jack" <Ja**@discussio ns.microsoft.co m> wrote in message
news:D4******** *************** ***********@mic rosoft.com...
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.

Mar 2 '06 #6
Bob, Actually I meant the text Year is displayed which is fine. The user need
to click on the Year (e.g. 2004) to choose from the list. However, as I
pointed out earlier that though 2004 is click I need to capture the
corresponding YearID which is 1 in the present case (i.e. the year 2004 is
chosen). Hope I am more clear now. I have got the sample code here. Any
thoughts.

"Bob Barrows [MVP]" wrote:
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.


The Value is not displayed, the text is. Try it.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Mar 2 '06 #7
OK,
this is just a test. In reality this is a much bigger data entry form where
various parties will enter 2004 and 2005 data via the web application. The
Year list box helps them to have their choice instead of typing the value in.
In the final table where all the data is collected the YearID is collected
rather than the YEAR text. Hope I am little more clear. Thanks

"Bob Lehmann" wrote:
I'm curious.

Since each year only happens once, why do you have a yearID column? I'm not
even really sure why you have a year table to begin with.

Unless you know something......

Bob Lehmann

"Jack" <Ja**@discussio ns.microsoft.co m> wrote in message
news:D4******** *************** ***********@mic rosoft.com...
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.


Mar 2 '06 #8

Jack wrote:
OK,
this is just a test. In reality this is a much bigger data entry form where
various parties will enter 2004 and 2005 data via the web application. The
Year list box helps them to have their choice instead of typing the value in.
In the final table where all the data is collected the YearID is collected
rather than the YEAR text. Hope I am little more clear. Thanks


As Bob has already pointed out a couple of times, with a Select list,
the value is passed with the form or querystring collection. So this:

<option value="somevalu e">Some Text</option>

will display "Some Text" on the screen, but if it is selected, will
pass "somevalue" to the collection. The only time "Some Text" will be
passed is if you either leave the option value blank, or explicitly
define the value as "Some Text". The latter is in effect what you are
doing with RS("Year").

Consequently, Bob's code will work in exactly the way you want it to.
Try the test as he suggested.

--
Mike Brind

Mar 2 '06 #9
Jack wrote:
Well Bob, I just trimmed my code to get a test asp page.
:-)
Obviously, you and i have different ideas about what constitutes a "small"
test 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,


This is why I told you to set the value attribut to the YearID instead of
the Year. here, try this to see:
<!-- #include file="connectio n.asp" -->
<!-- #include file="adovbs.in c" -->
<%
strSQL3 = "SELECT YearId, Year FROM tblYear"
Set RS_Year =conn.execute(s trsql3,,1)
if not rs_year.eof then arData=rs_year. getrows
rs_year.close:s et rs_year=nothing
conn.close: set conn=nothing
sHTML=""
if isarray(ardata) then
for i = 0 to ubound(ardata,2 )
shtml = shtml & "<option value = """ & _
ardata(0,i) & """>" & ardata(1,i) & "</option>"
next
end if
if len(request.for m("lstYear")) > 0 then
response.write "The value of the option you selected is """ & _
request.form("l stYear")
end if
%>
<html><body><fo rm method=POST >
<SELECT NAME= "lstYear" SIZE="1">
<%=shtml%>
</SELECT>
<input type="submit" value="Submit" >
</form></body></html>

--
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.
Mar 2 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3132
by: Danny Anderson | last post by:
Hola, PHP folk! I have a php page that contains a self-processing form. The form holds search results. The search terms originally came from the previous page, but the user can repeatedly refine the results on the page in question until the target item can be found. This search refinement is where the self-processing form comes to play. The search results are listed in a table with a radio button at the end of each row. What I...
1
2246
by: vishal | last post by:
hi i am using get method to pass data from one form to another and my value may contain & symbol. so when this is case the value after & sign is truncated which is logically true. so what should i do to solve this problem and if value contain ? symbol then it will make any difference????? i have not checked this but just it came in mind right now so i am
4
1530
by: Ronald S. Cook | last post by:
I have a form open and when a user clicks a button I do a frmNew.Show() and this.Hide. But I have a value that I need to pass to the new form. How can I do this, please? Thanks very much, Ron
0
1327
by: Jon Paal | last post by:
how can I pass conventional html upload form to asp.net page for processing / like : (which currently does not work) <form name="userForm" action="upload.aspx" ENCTYPE="multipart/form-data" method="post" > <input id="uploadedFile" type="file" > <input type="submit" id="upload" value="Upload" > </form>
1
1553
by: avni sanghvi | last post by:
i have created popup form in which listbox is used.when clicked on any item in listbox that value should be pass to the parent form for further processing. Please help me urgently thank u in advance
7
2576
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
5
3152
by: Jollywg | last post by:
Right now i have a C# program that has two forms frmHoliday, and frmNewHoliday. I need to pass a list of holidays from frmNewHoliday to frmHoliday. Right now it works using the Tag property. (From frmHoliday) private void btnAdd_Click(object sender, EventArgs e) { frmNewDate newHolidayForm = new frmNewDate();
1
961
by: bytesuser | last post by:
I'm trying to send a list of objects to a new window by reference, but get a compiler error saying my new window "does not contain a constructor that takes '1' arguments" Here's my constructor in the new window: private Options(ref List<Data> _DataList) And the code that calls it: Options OptionsWindow = new Options(ref DataList); What's going on? How do I pass a list of objects to a new window?
5
3305
by: DAHMB | last post by:
Hi, I have a form from which I open another form unsing the after update of a field I want to pass data from four fields of the original form to for fields of the newly opened form. I keep getting an error saying you can't assigne a value to this object. My after update is Private Sub Officer_LostFocus() If Me.Dirty Then Me.Dirty = False
0
8425
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8326
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8845
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8522
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5647
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4333
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2745
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.