473,395 Members | 2,446 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,395 software developers and data experts.

How can I retrieve the current value of a combobox in ASP?

JC
Hi,

I am having a very difficult time retrieving the value of the selected
item in the combo box using ASP. I have the following code, that
refreshes the page location when the combo box selection is changed.

<SELECT NAME="optionvalue"
onChange="document.location='/input.asp?optionvalue=<% =optionvalue
%>'">

The problem is that the variable optionvalue is never passed in the
URL, and I always end up with the same URL which is
'/input.asp?optionvalue='

If I replace the ASP statement with something like <% =int(rnd*10) %>
then it works fine, and the correct URL is formed, i.e.
'/input.asp?optionvalue=6'.

How can I go about resolving this issue? I am sure the solution is
very simple, but I have been trying for hours with little success.

Any help will be appreciated. Thanks in advance.

JC
Jul 19 '05 #1
2 3050
<select name="cboValues">
<option selected="opt1"> 1
<option> 2
<option> 3
</select>

<%
strval = request.form("cboValues")
response.write strval
%>

--
Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
JC <gs*****@hotmail.com> wrote in message
news:24*************************@posting.google.co m...
Hi,

I am having a very difficult time retrieving the value of the selected
item in the combo box using ASP. I have the following code, that
refreshes the page location when the combo box selection is changed.

<SELECT NAME="optionvalue"
onChange="document.location='/input.asp?optionvalue=<% =optionvalue
%>'">

The problem is that the variable optionvalue is never passed in the
URL, and I always end up with the same URL which is
'/input.asp?optionvalue='

If I replace the ASP statement with something like <% =int(rnd*10) %>
then it works fine, and the correct URL is formed, i.e.
'/input.asp?optionvalue=6'.

How can I go about resolving this issue? I am sure the solution is
very simple, but I have been trying for hours with little success.

Any help will be appreciated. Thanks in advance.

JC

Jul 19 '05 #2
JC wrote:
Hi,

I am having a very difficult time retrieving the value of the selected
item in the combo box using ASP. I have the following code, that
refreshes the page location when the combo box selection is changed.

<SELECT NAME="optionvalue"
onChange="document.location='/input.asp?optionvalue=<% =optionvalue
%>'">


<%=...%> is shorhand for <%Response.Write ... %>
Do you have a server-side variable called optionvalue? :-) I doubt it.

You need to use clientside code for this, making it offtopic for this news
group. However, this should work:

onChange="document.location='/input.asp?optionvalue=' +
event.srcElement.value"
Please post any follow-ups to this question to a group whose name contains
"dhtml", or to .scripting.jscript.

Bob Barrows
--
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 #3

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

Similar topics

6
by: Mendhak | last post by:
Hi All, When you add an object to a combobox, and run the application, you'll get something like this: System.Windows.Forms.Button, Text: Button1 (for example). Is it possible to have...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
by: tsteinke | last post by:
What is the syntax to refer to your current row in an SQL statement? I am using the "Lookup Wizard" to build a query in a table. How do you refer to the Current Row For instance I have a Table...
3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
12
by: Dica | last post by:
i can't seem to find a way to cast the value in my comboBox to integer. i've tried the following: short iProjectID = Convert.ToInt16(cboProjects.SelectedValue); i keep getting a "Sepcified...
1
by: dbuchanan | last post by:
Hello, I have the controls on my form display the values of the currently selected row of the dataGrid. There are a few fields that I have in my data table where I have the user select a value...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
7
by: shalskedar | last post by:
In a query i want to retrieve the value in such a way that if the value for the current record for a given column is 0 then it should go to the next record & take the value. for ex-I 've column...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.