Arithmetic
am 09.08.2007 20:55:20 von Raz
Hi,
I have seven radio buttons that a user might check and the values of the
buttons are 0, 1, 2, 3, 4, 5, and 6 for a response. The same variable name
is used for each radio button option (bdiq). Let's say that the user might
select radio button with the value of 4. Is there a way to "change" the
value from a 4 to a 2? This is what I have:
<%
Dim bdiq
Dim bdiqscore
Dim totalscore
totalscore = bdiqscore
if bdiq=4 then bdiqscore=bdiq-2 end if
%>
When I do response.write(bdiqscore), I get the answer of 2, but with
totalscore the answer is 4 from the radio button selected.
Thanks!
Re: Arithmetic
am 09.08.2007 21:15:42 von reb01501
Raz wrote:
> Hi,
>
> I have seven radio buttons that a user might check and the values of
> the buttons are 0, 1, 2, 3, 4, 5, and 6 for a response. The same
> variable name is used for each radio button option (bdiq). Let's say
> that the user might select radio button with the value of 4. Is
> there a way to "change" the value from a 4 to a 2? This is what I
> have:
>
> <%
> Dim bdiq
> Dim bdiqscore
> Dim totalscore
> totalscore = bdiqscore
>
> if bdiq=4 then bdiqscore=bdiq-2 end if
> %>
>
> When I do response.write(bdiqscore), I get the answer of 2, but with
> totalscore the answer is 4 from the radio button selected.
>
You seem to be thinking that "totalscore = bdiqscore" is a formula. It's
not. It is a value-assignment. it says: assign the value CURRENTLY held
by the bdiqscore variable to the totalscore variable. If bdiqscore
subsequently changes, totalscore will not change on its own! You have to
repeat the value-assignment
--
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.
Re: Arithmetic
am 09.08.2007 22:56:26 von Raz
Thanks! It's working now.
"Bob Barrows [MVP]" wrote in message
news:ulilvmr2HHA.5164@TK2MSFTNGP05.phx.gbl...
> Raz wrote:
>> Hi,
>>
>> I have seven radio buttons that a user might check and the values of
>> the buttons are 0, 1, 2, 3, 4, 5, and 6 for a response. The same
>> variable name is used for each radio button option (bdiq). Let's say
>> that the user might select radio button with the value of 4. Is
>> there a way to "change" the value from a 4 to a 2? This is what I
>> have:
>>
>> <%
>> Dim bdiq
>> Dim bdiqscore
>> Dim totalscore
>> totalscore = bdiqscore
>>
>> if bdiq=4 then bdiqscore=bdiq-2 end if
>> %>
>>
>> When I do response.write(bdiqscore), I get the answer of 2, but with
>> totalscore the answer is 4 from the radio button selected.
>>
> You seem to be thinking that "totalscore = bdiqscore" is a formula. It's
> not. It is a value-assignment. it says: assign the value CURRENTLY held
> by the bdiqscore variable to the totalscore variable. If bdiqscore
> subsequently changes, totalscore will not change on its own! You have to
> repeat the value-assignment
>
> --
> 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.
>
>
Re: Arithmetic
am 09.08.2007 23:05:03 von exjxw.hannivoort
Bob Barrows [MVP] wrote on 09 aug 2007 in
microsoft.public.inetserver.asp.general:
>> if bdiq=4 then bdiqscore=bdiq-2 end if
>> %>
>>
>> When I do response.write(bdiqscore), I get the answer of 2, but with
>> totalscore the answer is 4 from the radio button selected.
>>
> You seem to be thinking that "totalscore = bdiqscore" is a formula. It's
> not. It is a value-assignment. it says: assign the value CURRENTLY held
> by the bdiqscore variable to the totalscore variable. If bdiqscore
> subsequently changes, totalscore will not change on its own! You have to
> repeat the value-assignment
>
And
if bdiq=4 then bdiqscore=bdiq-2 end if
is an inline if-then, that should not have an "end if".
[That it works is a well documented vbs error
MS does not dare to correct.]
Use:
if bdiq = 4 then bdiqscore = bdiq - 2
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)