Click to See Complete Forum and Search --> : Creating or Setting a variable from Form


AnaFyr
11-03-2003, 09:24 PM
I need help trying to capture a value from a form that originates as a <SELECT> statement. Upon posting the form, I like to capture the data and store this into a variable that I can use later on in the script.

I'm currently returning a value to the ASP compiler via a Select Option on the Form.

<SELECT NAME="SelectNumberWeights">

<OPTION VALUE="1" SELECTED>1
<OPTION VALUE="2">2
<OPTION VALUE="3">3
<OPTION VALUE="4">4
<OPTION VALUE="5">5
<OPTION VALUE="6">6
<OPTION VALUE="7">7
<OPTION VALUE="8">8
<OPTION VALUE="9">9
<OPTION VALUE="10">10

</SELECT>

I'm capturing this information on the "called".asp Page.

Dim NumberOfWeights
NumberOfWeights = Request.Form ("SelectNumberWeights")

I have to set a price for each Option Value on the Form. I wanted to create a Function that could check the Value from the Form and according to it's value, set a variable to a chosen number.
By using the code above as an example:

IF "NumberOfWeights" variable is equal to "1" THEN
Set varExampleVariable to a certain price. By this I mean I want to set the variable with an Integer type.
I don't quite understand the scope of the Function declaration. I realize the point of naming the Function and declaring an implicit variable to capture the returning "value".

eg: Function FunctionName (varNewVariable)

I believe I need to execute an IF statement, or Select statement to see what the user selected; and according to that, set a specific price. Set it to a variable I can use later on in the script to manipulate with math operators.

I've tried a few different things including nested statements, but not sure if I really have it right. I know this can be done, I'm just too limited. HELP!

leprkn
11-03-2003, 09:54 PM
lemme see if i understand this right.

you got a select box w/ say 4 items 1-4. each item equals a price ie, 1=1.99 4=10.99

you can do this:
<select name="selectBox">
<option value="1.99" selected>1</option>
<option value="2.99>2</option>
...
<option value="10.99">4</option>

can you do that? seems as though it would be easier. then you wouldn't need a function to set the price. if you have the items pulled from a database this would be the way to go cuz then you only have to set the option value to your price record - that makes things dynamically easy.

i'd be of better help if i knew more about why you need a function to set the price

-lep