SunQuest
           Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old April 7th, 2003, 05:14 PM
ricesteam ricesteam is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 25 ricesteam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old April 7th, 2003, 07:13 PM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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>

Reply With Quote
  #3  
Old April 7th, 2003, 08:44 PM
ricesteam ricesteam is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 25 ricesteam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #4  
Old April 7th, 2003, 08:51 PM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: RE: Checkboxes; Simple Problem

Quote:
How would I combine that with PHP? Like store the count in a php $var? Or is there a better way?

Thanks.

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.

Reply With Quote
  #5  
Old April 7th, 2003, 09:41 PM
ricesteam ricesteam is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 25 ricesteam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #6  
Old April 8th, 2003, 07:55 PM
crisp crisp is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Holland
Posts: 336 crisp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: RE: Checkboxes; Simple Problem

Quote:
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

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).

Reply With Quote
  #7  
Old April 16th, 2003, 03:46 PM
mobeamer mobeamer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Charlotte, NC, USA
Posts: 10 mobeamer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Checkboxes; Simple Problem

you can make a checkbox part of an array by using this tag

php Code:
Original - php Code
  1.  
  2. for($i=0;$i<10;$i++)
  3.    print "<input type=checkbox name=yes[$i] value=1>";


when returning you can cycle through the array and check for values

php Code:
Original - php Code
  1.  
  2. for($i=0;$i<10;$i++)
  3.   $count += $yes[$i]


Hope that makes sense. I think theres a limit of 128 checkboxes (I think)

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Checkboxes; Simple Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway