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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing the selected value from a dropdown list for calculation

Status
Not open for further replies.

xcaliber2222

Programmer
Apr 10, 2008
70
US
Hello all, Could someone please show me how I could parse out the numeric value from an option selected value? Once I have this value then I can perform a calculation and return the value beside the control:

<option value="">Choose One</option>
<option selected="selected" value="Dell PC/$500.00">Dell PC/$500.00</option>
<option value="HP System/$600.00">HP System/$600.00</option>

If I could grab the 500.00 value then I could do a multiplication x whatever is input into the qty field. I can also have it displaying the value in a lable if that's easier to work with as far as parsing the value is concerned:

<span id="Label1">Dell PC/$500.00</span>

Any help would be greatly appreciated.

Thanks,
Alejandro
 
the problem is the value is not a number, it's text. I would recommend treating the value as an identifier and the text as the displayed information.

then you can easily grab the id from the option, reference the entity the id represents and preform your calculation.

also the markup above is standard HTML. in it's current form you will not be able to use webforms to access the information. You could get to it via the Request.Params/Form/QueryString collection using the asp.net pipeline though.

if this is a simple HTML question you may be better off to ask in forum215.



Jason Meckley
Programmer
Specialty Bakers, Inc.

faq855-7190
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top