ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 14th, 2003, 09:40 AM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
getting text from option boxes

ok i need to get the text from an option box? i know you can do it with java script but it would make my life a lot easier if you can get it using asp. don't know if there is a method out there or what. any ideas?
__________________
My brain cells are like a storm trooper's armor: useless

Reply With Quote
  #2  
Old August 14th, 2003, 09:44 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
What's an option box ?

Do you mean like a checkbox or a radio button ?

Either way, simply add a value attribute to the control of choice(checkbox or a radio button)

Then retrieve it like the usual!

<%
Dim strValue

strValue = Request.Form("...")
'OR
strValue = Request.QueryString("...")
%>


Hope this helps!
Sincerely

Vlince

Reply With Quote
  #3  
Old August 14th, 2003, 09:55 AM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
sorry should have been more specific.

<select>
<option value="<%databaserecordnumber%>"><%dbtext%>
</option>
</select>

i need the value to stay as the number so i can run other queries. i need the <%dbtext%> on form submit

Reply With Quote
  #4  
Old August 15th, 2003, 06:04 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 6
Send a message via AIM to unatratnag
If you assign a value, the name is not passed in the post, bummer huh?

my workaround is to instead of submitting to another page to have it be a button and onclick call javascript to open a new page and pass in variables in querystring to that do whatever, and if it needs to pass values back you can call any function from the parent page with window.opener.function_name() in the child window. I just found out about this last week so I'm still experimenting with it, but it works great from what i've seen. I can post some example when i go to work today if you need them....

Reply With Quote
  #5  
Old August 15th, 2003, 07:03 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Many ways to do that!

I personaly prefer having both values inside the value attribute of the <option> tag seperated by a delimiter

For example:

<select>
<option value="<%databaserecordnumber%>;<%dbtext%>"><%dbtext%>
</option>
</select>

Notice the --> ; <-- between <%databaserecordnumber%> and <%dbtext%>?

Now when you submit your <form>...</form>(Yes, I assumed you had a <form>...</form>) Then you simply retrieve the value of your <select>...</select> like this:


<%
Dim strSelectValues
Dim strSelectedText

'Notice the variable name strSelectValues its a plural name
'why? because it will hold the combination of :
'<%databaserecordnumber%> and <%dbtext%> seperated by a
'semicolon remember? So its gonna hold two values.
'Since the value YOU want is the second one(<%dbtext%>)
'what you do next is trivial...look!


strSelectValues = Trim(Request.Form("slc"))
'FOR DEBUG ONLY
'Response.Write "-->" & strSelectValues & "<--<hr>"
'Response.End


strSelectedText = Split(strSelectValues, ";")(1)
'FOR DEBUG ONLY
'Response.Write "-->" & strSelectedText & "<--<hr>"
'Response.End

%>

I've assumed, once again, that the name of your <select>...</select> was slc hence the :
Request.Form("slc")
I've also assumed your <form>...</form> was using the method POST hence the Request.Form

Now the tricky part, Split() returns an array but if you specify the element you want/need like in the above example:
Split(strSelectValues, ";")(1)
Notice the (1) it will return that element.

So your variable strSelectedText is NOT an array but a STRING hence the str prefix!

Arrays begin at 0 I wanted the second element in the array, I wanted the (1) which represents <%dbtext%>


Hope this helps!
Sincerely

Vlince

Reply With Quote
  #6  
Old August 15th, 2003, 07:44 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 6
Send a message via AIM to unatratnag
I don't think you'll need to write that book vlince, i think you've already written it. Just copy and past devshed excerpts you've written. My response would have just been to add the ; in and do a split, but you go all out and leave nothing to the imagination.

tell me when the book finally gets published, I'll want a signed copy haha.

Reply With Quote
  #7  
Old August 15th, 2003, 08:22 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Hehe
Nah...no books coming out although I'd like to but it might be in French since it's my native language

Not only that, but how can *I* compete with Jessy Liberty from O'reilly I mean c'mon

This guy's amazing!

Can we write articles here at devshed?
Do they pay for that?

Reply With Quote
  #8  
Old August 15th, 2003, 09:03 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 54 sec
Reputation Power: 6
Send a message via AIM to unatratnag
haha, if you ask them they'll say they pay you in satisfaction in knowing you helped someone out today

kinda like the, "mom, we have mom's day but when is kids' day?"
and she replies "why, everyday is kids day honey"

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > getting text from option boxes


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway