Home > Archive > ASP > August 2007 > Arithmetic
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
|
| 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!
| |
| Bob Barrows [MVP] 2007-08-09, 6:56 pm |
| 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.
| |
|
| Thanks! It's working now.
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:ulilvmr2HHA.5164@TK2MSFTNGP05.phx.gbl...
> Raz wrote:
> 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.
>
>
| |
| Evertjan. 2007-08-09, 6:56 pm |
| Bob Barrows [MVP] wrote on 09 aug 2007 in
microsoft.public.inetserver.asp.general:
> 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)
|
|
|
|
|