473,563 Members | 2,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting option's text value

Hi,

I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(.. .)

However, I am wondering if you can retrieve the text value using ASP??
I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?

Any input would be appreciated.... Thanks!

Apr 10 '07 #1
8 3891

Raul wote:
Hi,

I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(.. .)

However, I am wondering if you can retrieve the text value using ASP??
I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?

Any input would be appreciated.... Thanks!
You could append the value to the option value, eg: <option value="<
%=rsarr(0,i)%>: <%=rsarr(1,i)%> "><%=rsarr(1,i) %></option>

Then when you get the values
things = split(request.f orm("that"),":" )
optionvalue = things(0)
textvalue = things(1)

--
Adrienne Boswell at work
Administrator nextBlock.com
http://atlas.nextblock.com/files/
Please respond to the group so others can share

Apr 10 '07 #2
"Raul" wrote:
I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(.. .)

However, I am wondering if you can retrieve the text value using
ASP?? I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?
Yes, you can get the desired value. Use the value submitted and query the
database for the match.
Any input would be appreciated.... Thanks!
<input value="I hope this helped.">

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.

Apr 11 '07 #3
On 10 Apr, 13:13, "Raul" <aljam...@gmail .comwrote:
Hi,

I have a select list that gets populated from the DB. When the user
makes a selection I am able to retrieve this value via
Request.Form(.. .)

However, I am wondering if you can retrieve the text value using ASP??
I know this can be done in JavaScript using the options text
attribute, but it is possible in ASP?

Any input would be appreciated.... Thanks!
select.asp
<body>
<form name = form1 method = post action = "PrintSelectLis t.asp">
<select name = "cboTopping s" size = 4 multiple>
<option selected>Cheese
<option selected>Totmat o Sauce
<option>Olive Oil
<option>Barbecu e Sauce
<option>Peppero ni
<option>Sausa ge
<option>Mushroo ms
<option>Onion s
<option>Ham
<option>Pineapp le
<option>Green Peppers
<option>Anchovi es
</select>
<p>
<input type = submit name = cmdSubmit value = "Deliver It">
</p>
</form>
</body>
PrintSelectList .asp
<body>
<%
dim strSelect
dim i
strSelect = split(Request.F orm("cboTopping s"), ", ")
length = len(str)
for i = 0 to UBound(strSelec t)
response.write strSelect(i) & " "
next
%>
</body>
Apr 11 '07 #4
On Apr 11, 2:00 am, vinod...@gmail. com wrote:
select.asp
<body>
<form name = form1 method = post action = "PrintSelectLis t.asp">
<select name = "cboTopping s" size = 4 multiple>
<option selected>Cheese
<option selected>Totmat o Sauce
<option>Olive Oil
<option>Barbecu e Sauce
<option>Peppero ni
<option>Sausa ge
<option>Mushroo ms
<option>Onion s
<option>Ham
<option>Pineapp le
<option>Green Peppers
<option>Anchovi es
</select>
<p>
<input type = submit name = cmdSubmit value = "Deliver It">
</p>
</form>
</body>

PrintSelectList .asp
<body>
<%
dim strSelect
dim i
strSelect = split(Request.F orm("cboTopping s"), ", ")
length = len(str)
for i = 0 to UBound(strSelec t)
response.write strSelect(i) & " "
next
%>
</body>
Thanks for the input everyone. In the meantime I thought of a
solution that nobody else posted on here...I personally like it more.
Add an onclick event to the option element. Whenever it gets clicked,
save the text into a hidden form field. This value can then be used
as you like (I needed it to save the user input to the DB)

Cheers!
Apr 13 '07 #5
Raul wrote:
Thanks for the input everyone. In the meantime I thought of a
solution that nobody else posted on here...I personally like it more.
Add an onclick event to the option element. Whenever it gets clicked,
save the text into a hidden form field. This value can then be used
as you like (I needed it to save the user input to the DB)
Sure, that's one of the ways to do this, but why do you like it better?
Now you're at the mercy of a user who can easily disable javascript in
his browser.
--
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.
Apr 13 '07 #6
On Apr 13, 2:00 pm, "Bob Barrows [MVP]" <reb01...@NOyah oo.SPAMcom>
wrote:
Sure, that's one of the ways to do this, but why do you like it better?
Now you're at the mercy of a user who can easily disable javascript in
his browser.
Good point on that one, but I know all our users dont have JavaScript
disabled (its not a public site). If they had JavaScript disabled
then the site will not function properly.

To answer your question, I like it better because it seems more
elonquent than adding a delimiter to the value and appending the
description. Its just my opinion obviously, it is largely a stylistic
choice. Does anyone agree or am I on my own on this one?
Apr 13 '07 #7
Raul wrote:
Thanks for the input everyone. In the meantime I thought of a
solution that nobody else posted on here...I personally like it
more. Add an onclick event to the option element. Whenever it
gets clicked, save the text into a hidden form field. This
value can then be used as you like (I needed it to save the
user input to the DB)
I fail to see how that is an improvement over getting the value from the
database. The advantage of direct DB query is especially acute if the table
you are updating is in the same database as the one you are filling options
from, since you can simply do it in the DB at insert.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Apr 13 '07 #8
Raul wrote:
Good point on that one, but I know all our users dont have
JavaScript disabled (its not a public site). If they had
JavaScript disabled then the site will not function properly.
You are making far too many assumptions. I, for one, run the NoScript
extension when I browse the web. With it, I can temporarily turn on
scripting for a site, get past the non-working stuff, and turn it back off.
How exactly do you think you could circumvent that?

I don't even know where to begin with the Web Developer extension. There is
almost nothing you can do client-side to prevent me from controlling the
content of my requests. You should, therefore, concentrate on handling
requests, not dictating them.

To answer your question, I like it better because it seems more
elonquent than adding a delimiter to the value and appending
the description.
In the sense that it more explicitly divides the text and value, I agree
that this is a better approach than delimited concatenation. But neither is
robust.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.
Apr 13 '07 #9

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

Similar topics

8
1403
by: abbylee26 | last post by:
User enters account number if another account number is needed User clicks add account which creates another row When validating when they hit submit I want to check to make sure they tell us how much money to charge to all account numbers except the first one (all remaining money goes on the first account number) within the header...
10
2300
by: Chuck | last post by:
Hi! Any ideas as to how I can get ride of the script error undefined variable "Exp_Month"? I am trying to get this drop down list to default to the current month as opposed to 01. Thank you in advance.
12
1772
by: Adam Lipscombe | last post by:
Folks, I need to get the contents of a form attribute. In Read/Write mode this is field, so I can use getElementById("name").value In ReadOnly this is just plain text, so I can use getElementById("name").innerText. I need to do it dynamically though, so is there anyway I can look at the object returned by getElementById() and determine...
1
1945
by: bagya | last post by:
please help me out the following is the small code i have <html> <head> <script type="text/javascript"> function validate() { if (document.abc.region.value==0)
2
2105
by: pm1ccc | last post by:
Hi, I have written following code and not getting back values in the same form ( i have used phpself) <?php $Fname = $_POST; $Lname = $_POST; $gender = $_POST; $food = $_POST; $quote = $_POST;
1
3177
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as follows: The code below is for the first page:session_start is in line 3 <link href="css/jobSheet.css" rel="stylesheet" type="text/css" /> ...
10
2264
by: jonathan184 | last post by:
Hi I tried getting this to work through dreamweaver but it did not. So i found a n example on the internet , i followed everything exactly the search script does not work. Could somebody help me this please. Thanks for your help in advance. The form and script are on the same page. <?php require_once('../Connections/rs_ais.php'); ?> ...
9
2607
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of the main floors of the main house: Part C: Gross Floor Area of the basement or cellar: Part D: Gross Floor Area of the attic:
9
3532
vikas251074
by: vikas251074 | last post by:
I am not getting date value in spite of my good effort. This code was working in my last office where I work. Now I am trying to work at my home pc. but not getting date value. Any can help me why this happens. This is my part of code given below. <%@ Language=VBScript%> <%Option Explicit%> <html> <head> <title>SABF</title>...
7
4429
vikas251074
by: vikas251074 | last post by:
I am getting error above in following code since few days giving tension day and night. How can I solve this? I am facing since Oct.25. in line no. 362 After doing a lot of homework, I am surrendered to you. <%@ Language=VBScript%> <%Option Explicit%>
0
7658
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...
0
7876
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. ...
1
7630
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...
0
6235
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...
0
3628
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2077
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
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.