473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I get the dropdown's selected value

Hello
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?

Jul 19 '05 #1
24 77259
London wrote:
Hello
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?


Give the dropdown element a name, using its name property.

Then, in the asp page to which you are submitting the form, just do this (if
using POST):
<%
selectedvalue = request.form("name_of_dropdown")
.....
%>

or this, if using GET:
<%
selectedvalue = request.querystring("name_of_dropdown")
.....
%>

HTH,
Bob Barrows

Jul 19 '05 #2
> By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?


Using ASP, you'll have to resubmit your form first. After submitting your
form, try the following...

'Let's assume the name of your dropdown list is ControlName.
Response.Write request("ControlName")
Jul 19 '05 #3
<select name="XYZ">
<option value="1">One</option>
<option value="2">Two</option>
</select>

If method="post" -
Request.Form("XYZ")

If method="get"
Request.Querystring("XYZ")

Ray at work
"London" <lo************@yahoo.co.jp> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
Hello
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?

Jul 19 '05 #4
First it has to be in a Form and the Form has to be "Submitted" to an
ASP page. If the control's Name is "DdList", then the ASP page you
submitted to would retreive it with any one of these:

Request.Form("DdList")

How you handle it from that point is up to you.
--

Phillip Windell [CCNA, MVP, MCP]
pw******@wandtv.com
WAND-TV (ABC Affiliate)
www.wandtv.com

"London" <lo************@yahoo.co.jp> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
Hello
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?

Jul 19 '05 #5
In article <u1**************@TK2MSFTNGP12.phx.gbl>, louxiangyu2000
@yahoo.co.jp says...
Hello
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?

Man, you *are* an idoit!

-- Guinness
Jul 19 '05 #6
Don't listen to him, London. Everyone posting here started out as an egg
and a sperm and had to take it from there. You can post any questions here,
from total beginner level, to total expert level. Don't be discouraged by
the idoits [sic] who post nonsense.

Ray at work
"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .
In article <u1**************@TK2MSFTNGP12.phx.gbl>, louxiangyu2000
@yahoo.co.jp says...
Hello
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?

Man, you *are* an idoit!

-- Guinness

Jul 19 '05 #7
In article <#p*************@TK2MSFTNGP11.phx.gbl>, "Ray at <%
=sLocation%>" <myfirstname at lane34 dot com> says...
Don't be discouraged by the idoits [sic] who post nonsense.
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value?
What is it's property'name?

Man, you *are* an idoit!


I just wanted to use the word idoit!

Jul 19 '05 #8
In article <#p*************@TK2MSFTNGP11.phx.gbl>, "Ray at <%
=sLocation%>" <myfirstname at lane34 dot com> says...
Don't listen to him, London. Everyone posting here started out as an egg
and a sperm and had to take it from there. You can post any questions here,
from total beginner level, to total expert level. Don't be discouraged by
the idoits [sic] who post nonsense.

Ray at work


P.S. I notice you didn't answer his question... :-)
Jul 19 '05 #9
Ah, but I did.

"Guinness Mann" <GM***@dublin.com> wrote in message
news:MP************************@news.newsguy.com.. .

P.S. I notice you didn't answer his question... :-)

Jul 19 '05 #10
Actually you can just:
Request("XYZ")

It will look for querystring first then post if no
querystring is present. I use this ocassionally because
sometimes you need a user to post info to a page and I
may also have a direct link from another page with posted
info in the querystring as a shortcut.

-----Original Message-----
<select name="XYZ">
<option value="1">One</option>
<option value="2">Two</option>
</select>

If method="post" -
Request.Form("XYZ")

If method="get"
Request.Querystring("XYZ")

Ray at work
"London" <lo************@yahoo.co.jp> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
Hello
Can you help me.
By ASP
How can I get the dropdown(control'name)'s selected value? What is it's property'name?

.

Jul 19 '05 #11
That's totally inefficient and bound to cause bugs. You should always
explicitly state which collection you want to look in. All shortcuts waste
future time.

Ray at home

"Michael Ralph" <ra***@141.com> wrote in message
news:10****************************@phx.gbl...
Actually you can just:
Request("XYZ")

It will look for querystring first then post if no
querystring is present. I use this ocassionally because
sometimes you need a user to post info to a page and I
may also have a direct link from another page with posted
info in the querystring as a shortcut.

Jul 19 '05 #12
Michael Ralph wrote:
Actually you can just:
Request("XYZ")

It will look for querystring first then post if no
querystring is present. I use this ocassionally because
sometimes you need a user to post info to a page and I
may also have a direct link from another page with posted
info in the querystring as a shortcut.

This is not recommended. In addition to slowing down your code (due to
forcing all the Request collections to be searched, not just the Form and
Querystring collections), it can cause unintended results:
If you happen to use a control name in your form that is the same as the
name of a variable in the servervariables collection (such as "URL"), you
will get the servervariable value, not the form or querystring value.

It is better to do something like this:

sVar = Request.Form("XYZ")
if len(sVar) = 0 then sVar = Request.Querystring("XYZ")

Bob Barrows

Jul 19 '05 #13
Thank you very much.
but
I wrote this code:

dim xy
Response.Write "<FORM>"
Response.Write "<B><TR><SELECT name=""select1"" Width=394px>"
Response.Write "<OPTION value=""1"">One</OPTION>"
Response.Write "<OPTION value=""2"">Two</OPTION>"
Response.Write "</SELECT></TR></B>"
Response.Write "</FORM>" & Chr(13)
xy=Request.Querystring("select1")
Response.Write "<P><input type=""text"" id=""text1"" name=""text1""></P>"
Response.Write "<P><input type=""button"" value=""ButtonX""
onclick=""text1.value='" & xy & "';"" METHOD=""get"" id=button1
name=button1></P>"

I click the button(ButtonX),but the testbox(text1) is none.
Can you more help me

Jul 19 '05 #14
London wrote:
Thank you very much.
but
I wrote this code:

dim xy
Response.Write "<FORM>"
Response.Write "<B><TR><SELECT name=""select1"" Width=394px>"
Response.Write "<OPTION value=""1"">One</OPTION>"
Response.Write "<OPTION value=""2"">Two</OPTION>"
Response.Write "</SELECT></TR></B>"
Response.Write "</FORM>" & Chr(13)
xy=Request.Querystring("select1")
Response.Write "<P><input type=""text"" id=""text1""
name=""text1""></P>" Response.Write "<P><input type=""button""
value=""ButtonX"" onclick=""text1.value='" & xy & "';""
METHOD=""get"" id=button1 name=button1></P>"

I click the button(ButtonX),but the testbox(text1) is none.
Can you more help me


You're doing too much response.write'ing. This is very hard to follow (and,
it must be hard to write). Nevertheless, some problems do reveal themselves:

1. METHOD is an attribute of a FORM element, not an INPUT element
2. You aren't telling the form where it should be submitted - use the FORM
element's ACTION attribute
3. You aren't submitting the form - you need to
a. have a Submit input element within the FORM, or
b. have your button input element's onclick event include code to submit
the form
4. You do not seem to understand when the xy variable will be populated.
When an asp page is called on the server, all server-side code is executed
before the resulting html is sent to the client. So, in your code, when the
asp page is called, the hetml that is sent to the client browser includes
this code (which you can verify by using View Source in your browser
window):
<input type="text" id="text1" name="text1">
<input type="button" value="ButtonX"" onclick="text1.value='';"
METHOD=""get"" id=button1 name=button1>

You see? When this button is clicked, it will set the text1.value to a blank
string. And nothing else will happen.

But let's suppose that you also included code to submit the form. Assuming
you've set the ACTION attribute to submit the form to itself, when you submi
t the page after select "Two" in the dropdown, and it reloads in the client
browser, the html source of the reloaded page will look like this:
<input type="text" id="text1" name="text1">
<input type="button" value="ButtonX"" onclick="text1.value='2';"
METHOD=""get"" id=button1 name=button1>

So, the textbox will still be blank ... until you click the button. But,
when you click the button, the form will be resubmitted, so the user will
never have a chance to see the new value of the textbox.
Here is what I would do (this code has been tested - give it a try):

<%
'This page is called ASPPage6.asp
option explicit
dim xy
xy=Request.Querystring("select1")
%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<FORM action="ASPPage6.asp" method=GET id=form1 name=form1>
<SELECT id=select1 name=select1>
<OPTION value="1">One</OPTION>
<OPTION value="2">Two</OPTION>
</SELECT>
<INPUT type="submit" value="Submit" id=submit1 name=submit1>
<P>
<INPUT type="text" id=text1 name=text1 value="<%=xy%>">
</P>
</FORM>
</BODY>
</HTML>

When the page initially loads in the browser, the textbox will be blank.
When you select an option from the dropdown and click the Submit button, the
page will reload and the textbox will contain the selected value

HTH,
Bob Barrows
Jul 19 '05 #15
Thank you very much.
but
I wrote this code:

<%@ Language=VBScript %>
<%
option explicit
dim xy
xy=Request.Querystring("select1")
%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=x-sjis">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<FORM id=form1 name=form1 action=ASPPage6.asp method=get>
<SELECT id=select1 name=select1>
<OPTION value=1 selected>One</OPTION>
<OPTION value=2>Two</OPTION>
</SELECT>
<P><INPUT id=submit1 type=submit value=Submit name=submit1></P>
<P><INPUT id=text1 value="<%=xy%>" name=text1></P>
</FORM>
</BODY>
</HTML>

When I click the submit button,the page is error.Error message:
"
Page not found
....
HTTP 404 - Files not found
Internet Information Services
....
"
Can you more help me

Jul 19 '05 #16
Ummmm - replace "ASPPage6.asp" with the actual name of the asp page???

By the war, I very deliberately surrounded the attribute values (such as
"ASPPage6.asp") with quotes in the example I provided. I do not see quotes
in your new code here.

Bob Barrows

ondon wrote:
Thank you very much.
but
I wrote this code:

<%@ Language=VBScript %>
<%
option explicit
dim xy
xy=Request.Querystring("select1")
%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=x-sjis">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<FORM id=form1 name=form1 action=ASPPage6.asp method=get>
<SELECT id=select1 name=select1>
<OPTION value=1 selected>One</OPTION>
<OPTION value=2>Two</OPTION>
</SELECT>
<P><INPUT id=submit1 type=submit value=Submit name=submit1></P>
<P><INPUT id=text1 value="<%=xy%>" name=text1></P>
</FORM>
</BODY>
</HTML>

When I click the submit button,the page is error.Error message:
"
Page not found
...
HTTP 404 - Files not found
Internet Information Services
...
"
Can you more help me


Jul 19 '05 #17
SW
I have a similar task to "London's" and am having trouble finding the
easiest way to do it. I do have some asp experience but sometimes you
have to do new things...

I have built a form and have it submitting to the server fine. The
problem I am having is that in many text boxes I need to be able to go
"lookup" the value the user typed in and then populate another text
box with an answer (from another table).

Example:
The user is typing in a mechanical problem description. One field is
a "Part number" - when the user types that in and moves off that field
I have to go to another table with that part number and lookup the
"Description" of that part number, I then have to auto-fill that text
box on the screen. I can do it with a Submit button but the customer
wants this to happen automatically (!darn customers!) without having
to click on anything.

I have to use all VBScript because of customer requirements so I don't
think the OnBlur() attribute is available to me.

I thought I could put some VBScript lookup code in the 'value'
attribute of the "part number" field?? But I can't find any
examples of people doing this on any of these groups.

Anyone have some ideas or know where some examples of this might be?

Thanks for the help!

Susan Williamson
Jul 19 '05 #18
In article <f9**************************@posting.google.com >,
Su**************@amsec.com says...
The user is typing in a mechanical problem description. One field is
a "Part number" - when the user types that in and moves off that field
I have to go to another table with that part number and lookup the
"Description" of that part number, I then have to auto-fill that text
box on the screen. I can do it with a Submit button but the customer
wants this to happen automatically (!darn customers!) without having
to click on anything.


Susan, I don't understand your problem well enough to answer your
question, but I do have a couple of comments.

First, this problem would be trivial in .NET. Perhaps that's not an
option for you.

Secondly, another group here at work has a sort of related situation.
What they do is bring an entire table of data over to the client along
with the form. Then as the user moves around on the form they use
javascript to update various fields. Note that our application runs on
an intranet, and we have complete control over browsers and settings.

-- Rick

Jul 19 '05 #19


I need help to display the selected value from database in the dropdown
list. Following is my code...but there are some error:

while NOT rs.EOF
Response.Write ("<option value = '" & rs("Description") & "'")
Response.Write (">")
If rs("Description") = rsStatus("sc_status") Then
Response.Write ("<Option value = '" & rsStatus("sc_status") & "'
SELECTED>")
Else
Response.Write (rs("Description"))
Response.Write ("</option>")
rsStatus.MoveNext
end if
wend

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #20


You have to submit ur form under which your drop down element exist.
After submitting you can get it's value like this
to display
Response.Write request("NameOfcontrol")
to assign to some variable
ur variable request("NameOfcontrol")

Or you can even catch it with out submiting through java script.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #21

Guinness Mann no body is perfect is this IT world.Can u think bill gates
knows how to programme in Java . Absolutely not. So pls encourage other
fellow developers.
thanx
peace
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #22
janice li wrote:
I need help to display the selected value from database in the
dropdown list. Following is my code...but there are some error:


We are not looking over your shoulder at your screen. You need to tell us
what the errors are.

--
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.
Jul 19 '05 #23
while NOT rs.EOF
If rs("Description") = rsStatus("sc_status") Then
strSelect = "SELECTED"
else
strSelect = ""
end if

Response.Write ("<option value = '" & rs("Description") & "' " &
strSelect & ">")
Response.Write (rs("Description"))
Response.Write ("</option>")

rsStatus.MoveNext
wend

"janice li" <j_*****@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...


I need help to display the selected value from database in the dropdown
list. Following is my code...but there are some error:

while NOT rs.EOF
Response.Write ("<option value = '" & rs("Description") & "'")
Response.Write (">")
If rs("Description") = rsStatus("sc_status") Then
Response.Write ("<Option value = '" & rsStatus("sc_status") & "'
SELECTED>")
Else
Response.Write (rs("Description"))
Response.Write ("</option>")
rsStatus.MoveNext
end if
wend

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 19 '05 #24


Thanks a lot....

I got it already..

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #25

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

Similar topics

0
by: Kannan.M.R | last post by:
Hi, I have a problem in assigning the selected value in the dropdown to a hidden control. It goes like this. I have a repeater control. In the repeater control’s item template, I have a...
0
by: Kannan.M.R | last post by:
hi, I have a repeater. In the item template of the repeater i have a place holder control. In the item databound event of the repeater, In a for loop, i create dropdowns and buttons in a loop and...
1
by: Andy Sutorius | last post by:
Hi, I have 4 panels, each panel has a dropdown and a "next" button. I would like to get the selected value of the dropdown after the next button is clicked. I thought I could use the following...
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
1
by: Ben | last post by:
I have a formview with a few dropdownlists (software version, database version, etc). When a software version is selected, the database version dropdownlist updates itself accordingly. When in...
1
by: CorporateCoder | last post by:
Hi, I am trying to bind the selected value of a databound dropdown box in a databound gridview control to the value being displayed in the template column the dropdown box has been added to. ...
4
by: Ronny Mandal | last post by:
Hi! I have an .aspx with some controls that are created dynamically. The items are populated into the box by setting the DataSource-property to a list. In addition I specify the text and value...
17
by: jerrydigital | last post by:
Hello, I have an edit user page that allows the user to view their user information and make changes if possible. I have a simple html login page that directs to an asp page called edituser.asp...
1
by: techbytes | last post by:
hi, I have 2 dropdowns ,after populating the dropdown with selected values,the page is refreshed. so the selected value in the dropdown is not retained in the dropdown list. I want to retain...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...

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.