Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select .. option 1

Status
Not open for further replies.

JKingdom

Programmer
May 9, 2004
141
AE
if i have :

<select size="1" name="impo">
<option value="8">important</option>
<option value="10">very important</option>

then i have

importance = Request.form ("impo")

this well give me the value ..
what if i want to request the option not the value .. like (important or very importance) not 8 or 10 ..

considering that i need 8 and 10 in other calculations so i can't put important as a value ..

 
>what if i want to request the option not the value .. like (important or very importance) not 8 or 10 ..
Let's look at it this way. The option's text is for client's consumption whereas the value if for server's. If you need the option text as well without a table of correspondance back there on the server (remember the page's designers have an undeniable control over the page design), you have to device a hidden field and synchronize it with some onchange handler of the select element and initiate it in accordance with the select default selectedIndex.
 
then have a table in your database with the following:

Code:
RatingID | RatingDesc      | RatingValue
___________________________________
   1     |  Important      |    8
   2     |  Very Important |    9


-DNG
 
Here are a couple of quick & dirty methods:

Code:
<select size="1" name="impo">
  <option value="8_important">important</option>
  <option value="10_very important">very important</option>
</select>

.
.
.
importance = Left(Request.Form("impo"), InStr(Request.Form("impo"), "_") -1 ))
importanceDesc = Mid(Request.Form("impo"), InStr(Request.Form("impo"), "_") + 1))


or


Code:
<select size="1" name="impo">
  <option value="8">important</option>
  <option value="10">very important</option>
</select>

.
.
.
importance = Request.form("impo")
Select Case importance
  Case 8
   importanceDesc = "important"
  Case 10
   importanceDesc = "very important"
End Select

Overall though, the database method is cleaner and a better design.
 
Or even a simple dictionary object... as long as the action page has access to and looks up the correspondance. It's up to the page designer.
 
Dictionary object is another good idea if all users will have the same values in their dropdown... that way you can use a single instance of the object in an Application variable instead of one instance for each user in a Session variable.
 
yeah .. i created a table as DotNetGnat recommended .. ;) .. thanks alot
 
Why would you assign a numeric value to the level of importance when you don't want that, you want the text? Just use the text in both places instead.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
i need it coz there is a calculation required .. for example ..

Important 8
Unimportant 2
v.important 10


Acceptable 6
Dangerous 10
Safe 4
Unsafe 8
v.safe 1

then there is calculation based on the factors :)

anyways thanks alot ..its solved already .. ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top