Search the web
Sign In
New User? Sign Up
JS-Jive · The premiere Yahoo! Javascript Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
checkbox values?   Message List  
Reply | Forward Message #21064 of 21091 |
checkbox values?


I have a form with three checkboxes, and want to set another variable
depending on which boxes are checked.

The boxes have values of 1, 2, and 4, and I want to add up the values
of whichever boxes are checked.

The problem is that I'm getting a value of 7 no matter what boxes are
checked.

Any ideas?

---------------------------------


<script language="javascript">
<!--
function getbase() {

var b1 = document.form1.base1.value;
var b2 = document.form1.base2.value;
var b3 = document.form1.base3.value;

document.form1.bases.value = parseFloat(b1) + parseFloat(b2) +
parseFloat(b3);

}
//-->

</script>

</head>

<body>

<form name="form1">

1<input type="checkbox" name="base1" value="1">
2<input type="checkbox" name="base2" value="2">
3<input type="checkbox" name="base3" value="4">

<br><br>

<input name="bases" type="text">

<br><br>

<input type=submit onclick="getbase()">


</form>






Sat Mar 24, 2007 3:13 am

caitlin_weaver
Offline Offline
Send Email Send Email

Forward
Message #21064 of 21091 |
Expand Messages Author Sort by Date

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 28, 2007
11:06 pm

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 28, 2007
11:13 pm

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 28, 2007
11:19 pm

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 28, 2007
11:35 pm

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 28, 2007
11:38 pm

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
12:01 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
12:02 am

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 29, 2007
12:03 am

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 29, 2007
1:06 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
1:09 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
1:57 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
2:02 am

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 29, 2007
2:52 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
3:05 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
3:09 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
3:56 am

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 29, 2007
6:14 am

... Exactly -- you're adding *all the values* regardless of whether the box is "successful", i.e. checked. :-) Untested, but something like var b1 =...
Hassan Schroeder
laughingandj...
Offline Send Email
Mar 29, 2007
7:22 am

I have a form with three checkboxes, and want to set another variable depending on which boxes are checked. The boxes have values of 1, 2, and 4, and I want to...
caitlin_weaver
Offline Send Email
Mar 29, 2007
1:23 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help