如何将列表框的代码传递给处理表单 [英] How to pass a code of a list box to a processing form

查看:52
本文介绍了如何将列表框的代码传递给处理表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个asp表单,其中一个元素是一个列表框,从2004年开始列出四年

。此列表来自数据库表将YearID

和Year作为两个字段,如下所示:

YearID年份

1 2004

2 2005

3 2006

4 2007

ASP代码的一部分是:


< 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"


<%请不要RS_Year.EOF

Response.Write"< Option Value =''" ; &安培; RS_Year(QUOT; YEAR")及"''>"

Response.Write RS_Year(" YEAR")& "< / OPTION>"

RS_Year.MoveNext

Loop

%>

< td>

< tr>


现在我想捕获YearCode的值而不是Year字段

和将年份代码值存储在处理表单中以在sql

语句中处理。


即我计划使用Request.Form(lstYear ;)捕获年份代码的价值

。但是,Request.Form(listYear)没有显示任何价值。

我会感谢任何帮助或任何文章链接来处理这个问题。

提前感谢。


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
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.


推荐答案

杰克写道:

我有一个asp表单,其中一个元素是一个列表框,列出从2004年开始的四年。这个列表来自数据库表
,其中YearID和Year为两个字段,如下所示:
YearID YEAR
1 2004
2 2005
3 2006年
4 2007年
ASP代码的一部分是:

< tr>
< td width =" 74%" align =" center" height =" 18">< font face =" Times New
Roman"大小= QUOT; 3英寸color =" red"> YEAR< / font>< / td>
< td>
< SELECT NAME =" lstYear" SIZE =1>

<%请不要RS_Year.EOF
Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEAR")及"''>"
Response.Write RS_Year(" YEAR")& "< / OPTION>"
RS_Year.MoveNext
循环
%>
< td>
< tr>

现在我想捕获YearCode的值而不是


那么为什么你使用RS_Year(YEAR)作为选项值?它不会使它更有意义将它改为:


Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEARID")及"''>"


年份字段并将年代码值存储在处理表单中以在sql语句中处理。
即我计划使用Request.Form(lstYear)来捕获年份代码的
值。但是,Request.Form(listYear)显示没有价值。
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
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("lstYear") to capture the
value of the year code. However, Request.Form("listYear") is showing
no value.




在这个过程的哪个阶段?提交包含上述

SELECT元素的表单后?


创建一个小测试表单,重现问题并发布整个

来自那个SMALL测试表的代码。


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。



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.


感谢Bob的帮助。我打算这样做。但是,我使用

RS_Year(YEAR)作为选项值的原因是我想在列表框中显示所有YEAR

值表格。但是,而不是年份我需要

捕获YEAR的相应代码的值。这段代码在处理asp页面的sql语句中转到了
。谢谢。


Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEARID")及"''>"

" Bob Barrows [MVP]"写道:
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:
杰克写道:

我有一个asp表单,其中一个元素是一个列表框,其中列出了四个
这个列表来自数据库表
,其中YearID和Year为两个字段,如下所示:
YearID年份
1 2004年
2 2005年> 3 2006
4 2007
ASP代码的一部分是:

< tr>
< td width =" 74%" align =" center" height =" 18">< font face =" Times New
Roman"大小= QUOT; 3英寸color =" red"> YEAR< / font>< / td>
< td>
< SELECT NAME =" lstYear" SIZE =1>

<%请不要RS_Year.EOF
Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEAR")及"''>"
Response.Write RS_Year(" YEAR")& "< / OPTION>"
RS_Year.MoveNext
循环
%>
< td>
< tr>

现在我想捕获YearCode的值而不是
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



那么为什么你使用RS_Year(YEAR)作为选项值?将它更改为更有意义吗



Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEARID")及"''>"



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")& "''>"

年份字段并将年代码值存储在处理表单中以在sql语句中处理。

即我计划使用Request.Form(lstYear)来捕获年份代码的
值。但是,Request.Form(listYear)显示没有价值。
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("lstYear") to capture the
value of the year code. However, Request.Form("listYear") is showing
no value.



在这个过程的哪个阶段?提交包含上述
SELECT元素的表单后?

创建一个小的测试表单,重现问题并从该SMALL测试表中发布整个
代码。

-
Microsoft MVP - ASP / ASP.NET
请回复新闻组。我的From
标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将得到更快的回复。



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.



好吧Bob,我只是修剪了我的代码以获得测试asp页面。请注意

,tblYear有YearId和Year字段。我需要显示年份值,

然后使用请求对象在

处理表单中捕获YearId(即列表框中选定的一个)。这个YearId将在处理表格中使用sql语句

。这是我的主要问题,即。如何在列表框中显示一个

字段,然后使用请求表单对象从

处理asp页面中的表单中捕获相应的ID。希望我能解释清楚。

这是测试页面的代码。谢谢。此致,


<! - #include file =" connection.asp" - >

<! - #include file =" adovbs.inc" - >


< HTML>

< HEAD>

< META NAME =" GENERATOR" Content =" Microsoft Visual Studio 6.0"

< / HEAD>


< center>

< ; h2>

< b>

< font size =" 5" color =" navy">

TEST

< / font>

< / b>

< / h2>

< / center>


< BODY>



<%

设置RS_Year = Server.CreateObject(" ADODB.Recordset")

strSQL3 =" SELECT YearId,Year FROM tblYear"

RS_Year.Open strSQL3,conn


%>

< form method = POST name =" frm_mainentry" action =" mainentry_process.asp"

onSubmit>

< div align =" center">

< table border = " 1 QUOT;宽度= QUOT; 80%"高度= QUOT 1 QUOT; cellspacing =" 1">

< tr>

< td width =" 50%" align =" center" height =" 18">< font face =" Times New Roman"

size =" 3" color =" red"> COUNT TOTAL OFFENSES< / font>< / td>

< td width =" 50%"对齐= QUOT;中心" BGCOLOR = QUOT;白" height =" 18">< font

face =" Times New Roman" size =" 1">

< input type =" text"名称= QUOT; txt_CountTotalOffenses" size =" 57"

style =" font-family:Times New Roman; font-size:12pt">< / font>< / td>

< / tr>

<%''Response.End%>


< 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"


<%请不要RS_Year.EOF

Response.Write"< Option Value =''" ; &安培; RS_Year(QUOT; YEAR")及"''>"

Response.Write RS_Year(" YEAR")& "< / OPTION>"

RS_Year.MoveNext

Loop

%>

< td>

< tr>

<%''Response.End%>


< tr>

< td width =" 100%"对齐= QUOT;右" colspan =" 2" height =" 27">< p>< input

type =" submit"值= [提交" name =" B3">< / td>

< / tr>


< / table>

< / div>

< / form>


< / BODY>

< / HTML>


" Jack"写道:
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="connection.asp" -->
<!-- #include file="adovbs.inc" -->

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>

<center>
<h2>
<b>
<font size="5" color="navy">
TEST
</font>
</b>
</h2>
</center>

<BODY>


<%
Set RS_Year = Server.CreateObject("ADODB.Recordset")

strSQL3 = "SELECT YearId, Year FROM tblYear"
RS_Year.Open strSQL3, conn

%>
<form method=POST name="frm_mainentry" action="mainentry_process.asp"
onSubmit>
<div align="center">
<table border = "1" width="80%" height="1" cellspacing = "1">
<tr>
<td width="50%" align ="center" height="18"><font face="Times New Roman"
size="3" color = "red">COUNT TOTAL OFFENSES</font></td>
<td width="50%" align="center" BGCOLOR="white" height="18"><font
face="Times New Roman" size="1">
<input type="text" name="txt_CountTotalOffenses" size="57"
style="font-family: Times New Roman; font-size: 12pt"></font></td>
</tr>
<%''Response.End%>

<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>
<%''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:
感谢Bob的帮助。我打算这样做。但是,我使用
RS_Year(YEAR)作为选项值的原因是我想在表单的列表框中显示所有YEAR
值。但是,而不是年份我需要
捕获YEAR的相应代码的值。此代码转到处理asp页面中的sql语句。谢谢。

Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEARID")及"''>"

" Bob Barrows [MVP]"写道:
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:
杰克写道:

我有一个asp表单,其中一个元素是一个列表框,其中列出了四个
这个列表来自数据库表
,其中YearID和Year为两个字段,如下所示:
YearID年份
1 2004年
2 2005年> 3 2006
4 2007
ASP代码的一部分是:

< tr>
< td width =" 74%" align =" center" height =" 18">< font face =" Times New
Roman"大小= QUOT; 3英寸color =" red"> YEAR< / font>< / td>
< td>
< SELECT NAME =" lstYear" SIZE =1>

<%请不要RS_Year.EOF
Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEAR")及"''>"
Response.Write RS_Year(" YEAR")& "< / OPTION>"
RS_Year.MoveNext
循环
%>
< td>
< tr>

现在我想捕获YearCode的值而不是
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



那么为什么你使用RS_Year(YEAR)作为选项值?将它更改为更有意义吗



Response.Write"< Option Value =''" &安培; RS_Year(QUOT; YEARID")及"''>"



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")& "''>"

年份字段并将年代码值存储在处理表单中以在sql语句中处理。

即我计划使用Request.Form(lstYear)来捕获年份代码的
值。但是,Request.Form(listYear)显示没有价值。
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("lstYear") to capture the
value of the year code. However, Request.Form("listYear") is showing
no value.



在这个过程的哪个阶段?提交包含上述
SELECT元素的表单后?

创建一个小的测试表单,重现问题并从该SMALL测试表中发布整个
代码。

-
Microsoft MVP - ASP / ASP.NET
请回复新闻组。我的From
标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将得到更快的回复。



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.



这篇关于如何将列表框的代码传递给处理表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆