true and false

# Thread: true and false

1. Senior Member
Join Date
Dec 1969
Posts
1,671

## true and false

I have two radio buttons that are dynamically populated from the database. They are checked True or False. depending whats in the db. Is there anyway to set the True and False values to 1 and 0 so I can use them in a calculation?<BR><BR>I&#039;m using an Access database if this helps<BR><BR>thanks

2. Senior Member
Join Date
Dec 1969
Posts
1,912

## simple if

If var = false then<BR>var2 = 0<BR>else <BR>var2 = 1<BR>end if

3. Senior Member
Join Date
Dec 1969
Posts
1,671

## RE: simple if

How will that work with Javascript for the calculations?<BR><BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
1,912

## More details!

I&#039;m not really sure what you want to calculate if you only have two value? and they are 1 and 0?<BR><BR>A little more detail please!

5. Senior Member
Join Date
Dec 1969
Posts
1,671

## RE: More details!

On my web page I have several fields that are being calculated. and in the calculation I mulitple the value of the true and false buttons in the calculation to get the final results.<BR><BR>Example Code:<BR><BR>this is the javascript code for the calc.<BR>aupremium = a number <BR>auren = True or False<BR>var acctrent = (form.aupremium.value)*(form.auren.value))/(form.exprevenue.value)*-1; <BR><BR>this is the output for the true or false radio buttons.<BR>&#060;input type="radio" name="auren" value="true" &#060;% if rs("auren") = true then response.write "checked" end if %&#062; class="body" onClick="update(form)"&#062;&nbsp;<BR><BR>&#060;in put type="radio" name="auren" value="false" &#060;% if rs("auren") = false then response.write "checked" end if %&#062; class="body" onclick="clearauto(this.form)"&#062;&#060;/td&#062;<BR> <BR>thanks for any help

6. Senior Member
Join Date
Dec 1969
Posts
1,912

## OK

Something like this<BR><BR>&#060;Script&#062;<BR>if (document.formname.auren.value == "true")<BR>{<BR>do your calculation with 1<BR>}<BR>else if (document.formname.auren.value == "false")<BR>{<BR>do your calculation with 0, or don&#039;t do it at all!<BR>}<BR><BR>&#060;/script&#062;<BR><BR>HTH<BR>Dave

7. Senior Member
Join Date
Dec 1969
Posts
1,671

## RE: OK

Thanks,<BR><BR>That looks like that will work thank you

8. Senior Member
Join Date
Dec 1969
Posts
1,912

## No worries! :-)

.

9. Senior Member
Join Date
Dec 1969
Posts
1,671

## RE: No worries! :-)

One more question, can that if statement work with multiple radio buttons that are true or false?<BR><BR>they are all part of the calculation

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•