You can count the number of times a checkbox has been clicked with
Javascript:

<script language="javascript">
        function addClick(){
                nTemp = Number(document.forms[0].numOfClicks.value);
                document.forms[0].numOfClicks.value = nTemp + 1;
        }
</script>
<form method="post" action="">
        <input type="text" name="numOfClicks" value="0">
        <input type="checkbox" name="ourbox" onclick="addClick();">
</form>


However, I think using a checkbox will confuse the user. Perhaps you should
have a '+' and '-' icon next to a quantity field.  Like this:

<script language="javascript">
        function addClick(){
                nTemp = Number(document.forms[0].numOfClicks.value);
                if(isNaN(nTemp)){
                        nTemp = 0;}

                document.forms[0].numOfClicks.value = nTemp + 1;
        }

        function delClick(){
                nTemp = Number(document.forms[0].numOfClicks.value);
                if(isNaN(nTemp))
                        nTemp = 0;

                if(nTemp > 0)
                        document.forms[0].numOfClicks.value = nTemp - 1;
                else
                        document.forms[0].numOfClicks.value = nTemp;
        }
</script>

<form method="post" action="">
        <a href="javascript:addClick();">add</a>
        <a href="javascript:delClick();">remove</a>
        <input type="text" name="numOfClicks" value="0">
</form>


---
Paul Mone
Ninthlink Consulting Group
[EMAIL PROTECTED]
619.222.7082


-----Original Message-----
From: t nelson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 15, 2000 5:30 PM
To: CF-Talk
Subject: Counting Checkboxes


Hi all,

I have an application that i am building where the end user can pull up
multiple peripheral parts for any given base system(s). After that they can
select the peripheral parts they want by selecting the corresponding
checkboxes. Next, the user is able to enter the number of parts they would
like to purchase.

I have already set it up so that the page where the user can enter in
quantity, lists every part they selected. Here's the problem:

I want the quantity field to be filled in as the page is loaded. more to the
point the user can select more than one of the same peripheral part as some
parts have multi-compatibility(ie printer cables, they go with just about
everything). Is there a way for me to count the number of times a checkbox
is selected? Otherwise I would have to either leave the field blank or hope
the user can remember how many printer cables they need for each of their
base systems?

so far I have only been able to default it to 1. which doesn't work if the
user has selected more than one of the same part.

any ideas out there?

Thanks in advance everyone.

nelson
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]

------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message 
with 'unsubscribe' in the body to [EMAIL PROTECTED]

Reply via email to