so why are you doing that??
then you are only going to loop around 13 of the elements (or whatever
obj.clen.value is), you want to loop around the whole checkbox array....
which is 'document.frmVote.o.length' in your case if i read the code
right...
so loop through all of them and see which ones are checked...
2 bugs in my code are that i forgot a form name and the value to check is
not 1 but true.....
also, arrays start with 0 not 1....
so.... updated...
////////////////////////////////////////////////////////////////
len=document.frmVote.o.length
cnt = 0
for(i=0; i<=len-1; i++) {
if (document.frmVote.o[i].checked == true)
{
cnt++;
}
}
//cnt should be equal to the number that are checked....
////////////////////////////////////////////////////////////////
I just noticed something else, why do you have different names for each
checkbox, they all should be in the same checkbox group....
i would keep the same name for all the checkboxes and use the above code...
personally speaking...
Terry Bader
IT/Web Specialist
EDO Corp - Combat Systems
(757) 424-1004 ext 361 - Work
[EMAIL PROTECTED]
(757)581-5981 - Mobile
[EMAIL PROTECTED]
icq: 5202487 aim: lv2bounce
http://www.cs.odu.edu/~bader
> -----Original Message-----
> From: PEREZ, RICHARD RINGO (SBCSI) [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 29, 2001 1:28 PM
> To: CF-Talk
> Subject: RE: Javascirpt problem on CF
>
>
> No, len is a variable that is determining how many is he
> going to check...
> the len value here should be 34.
>
> -----Original Message-----
> From: Terry Bader [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, March 29, 2001 10:00 AM
> To: CF-Talk
> Subject: RE: Javascirpt problem on CF
>
>
> I have not tested this, but I think this is a generic form or what you
> want...
> the main thing i see that can be wrong in your code is here:
> len = parseFloat(obj.clen.value)
> is this the length?? obj.clen.value?? maybe obj.clen.length
>
> hope this helps....
> ////////////////////////////////////////////////////////////////
> len=document.checkboxes.length
> cnt = 0
>
> for(i=1; i<=len; i++) {
> if (document.checkboxes[i].checked == 1)
> {
> cnt++;
> }
> }
>
> //cnt should be equal to the number that are checked....
> ////////////////////////////////////////////////////////////////
>
>
> Terry Bader
> IT/Web Specialist
> EDO Corp - Combat Systems
> (757) 424-1004 ext 361 - Work
> [EMAIL PROTECTED]
>
>
> (757)581-5981 - Mobile
> [EMAIL PROTECTED]
> icq: 5202487 aim: lv2bounce
> http://www.cs.odu.edu/~bader
>
>
>
>
>
>
> > -----Original Message-----
> > From: PEREZ, RICHARD RINGO (SBCSI) [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, March 29, 2001 12:33 PM
> > To: CF-Talk
> > Subject: Javascirpt problem on CF
> >
> >
> > This is my code with Javascript can you pelase help me figure
> > out what's
> > wrong? i know that Javascript is a client side while CF is
> > server side. Can
> > you please help me out to figure what changes do i need to
> > do on my code?
> >
> > What i'm trying to do on my code is they need to click on the
> > checkbox and i
> > will count how many checkboxes they already clicked on and
> > they should have
> > a max of 13 clicks.
> >
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> >
> > <html>
> > <head>
> > <title></title>
> >
> > <link href="../Styles/css.css" rel="stylesheet" type="text/css">
> >
> > <script language="JavaScript">
> > var cnt_chk = 0;
> > var cnt_sel = 0;
> >
> > function validate(obj){
> > len = parseFloat(obj.clen.value)
> >
> > cnt_chk = 0
> > for(i=1; i<=len; i++)
> > {
> > byVal = eval("obj.o" + i + ".checked")
> > if(byVal == true)
> > {
> > cnt_chk++
> > }
> > }
> >
> > if(cnt_chk == 0)
> > {
> > alert("You must select a Candidate");
> > return false;
> > }
> >
> > if(cnt_chk >= 14 OR cnt_chk <=12)
> > {
> > alert("You must select exactly 13 Candidates");
> > return false;
> > }
> > }
> >
> > function fnCountNatin(obj){
> > cnt_sel = 0;
> > len = parseFloat(document.frmVote.clen.value)
> >
> > for(i=1; i<=len; i++)
> > {
> > byVal = eval("document.frmVote.o" + i +
> > ".checked")
> > if(byVal == true)
> > {
> > cnt_sel++
> > }
> > }
> > document.frmvote.total_sel.value = cnt_sel++
> > }
> >
> > function fnTotal(obj){
> > alert("number of Candidates selected: " +
> > obj.value + " ")
> > return false;
> > }
> > </script>
> >
> > </head>
> >
> > <body VLINK="#990099" LINK="Blue" TEXT="Black"
> > ALINK="#7204C3" leftmargin=0
> > topmargin=0>
> >
> >
> >
> > <cfquery name="GetC" datasource="xxx" dbtype="ODBC">
> > Select CID, CFirstName, CLastName, CNickName, CParty
> > From Candidate
> > </cfquery>
> >
> >
> > <form action="Update/add_vote_form.cfm" method="post" name="frmVote"
> > onSubmit="return validate(this)">
> >
> > Unang Hakbang: Email <input type="Text" name="Email"
> > required="No" size="30"
> > maxlength="50">
> >
> > <P>
> > Pangalawang Hakbang:<br>
> > <table align="center">
> > <tr>
> > <td></td>
> > <td>Mga Kandidato</td>
> > <td>Party</td>
> > </tr>
> > <cfoutput query="GetC">
> > <tr>
> > <td><input type="Checkbox" name="o#GetC.CID#" value="#GetC.CID#"
> > onClick="fnCountNatin(this)"></td>
> > <td>#GetC.CFirstName# #GetC.CLastName# #GetC.CNickName#</td>
> > <td>#GetC.CParty#</td>
> > </tr>
> > </cfoutput>
> > </table>
> > <p>
> > Pangatlong Hakbang:<br>
> > <input type="hidden" name="clen" value="34">
> > Number of Candidates selected:
> > <input type="text" name="total_sel" maxlength="2" size="3" value="0"
> > onclick="return fnTotal(this)" onkeypress="javascript:return
> > fnTotal(this)"><br>
> > <input type="submit" name="Submit" value=" Vote! ">
> > </form>
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists