|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
Checkboxes; Simple Problem
Hi, thanks for all you who helped me thus far!
Anyways, I know I can search for a solution for my problem on tutorial sites but I dunno what to look up. I look up checkboxes but I just get information on how to set up the tag which I know. The problem is I want to determine how many checks a user has made in a given amount of checkboxes. How would I go to accomplish this? Thanks again |
|
#2
|
|||
|
|||
|
RE: Checkboxes; Simple Problem
something like:
<script type="text/javascript"> function countchecks() { var el = document.forms[0].elements; var count = 0; for (var i = 0; i < el.length; i++) { if (el.type == 'checkbox' && el.checked) count++; } alert(count); } </script> |
|
#3
|
|||
|
|||
|
RE: Checkboxes; Simple Problem
My form will contain more then just checkboxes; it will contain text, radio, etc...so how and where do I call the function above?
Also How would I combine that with PHP? For example, store the var count in a php $var? Or is there a better way? Thanks. |
|
#4
|
|||
|
|||
|
RE: RE: Checkboxes; Simple Problem
Quote:
ok, maybe I should have asked what you intend to do with the count in the first place. Do you need it in PHP? For what purpose? With that info I may be able to give you a better answer. There is no other way to return something from javascript to PHP than including it in a form or adding it to the url and do a postback to the server; clientside and serverside are two total different environments only connected through HTTP requests back and forth. |
|
#5
|
|||
|
|||
|
RE: Checkboxes; Simple Problem
yea I do need it in php, because I am requred to insert into a mySQL table afterwards.
So is it still possible to retrieve the amounts of checks a user makes, in php of course? cheers |
|
#6
|
|||
|
|||
|
RE: RE: Checkboxes; Simple Problem
Quote:
If you have a way to distinguish the checkboxes from the other inputs (either by name or by value) you can just walk through the $_POST array and count how many items you can find (checkboxes that are not checked are not being sent with the form). |
|
#7
|
|||||
|
|||||
|
RE: Checkboxes; Simple Problem
you can make a checkbox part of an array by using this tag
php Code:
when returning you can cycle through the array and check for values Hope that makes sense. I think theres a limit of 128 checkboxes (I think) |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Checkboxes; Simple Problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|