digitalgod Posted September 13, 2006 Share Posted September 13, 2006 hey guys,I'm trying to limit the number of checkboxes a user can check. Need the limit to be dynamic but for testing purposes I'm trying to do it with a fixed number. the checkboxes look like this<input type="checkbox" name="winner[]" value="'.$row['username'].'"> is there any way of doing that if the name of the checkbox is an array? It really needs to be like that. Link to comment https://forums.phpfreaks.com/topic/20579-limiting-the-number-of-checkboxes-checked/ Share on other sites More sharing options...
degsy Posted September 18, 2006 Share Posted September 18, 2006 http://degs.co.uk/test/hct/loop_through_checkbox_check_limit.htmhttp://degs.co.uk/test/hct/loop_through_checkbox_check_limit_php_array.phphttp://degs.co.uk/test/hct/loop_through_checkbox_check_limit_to_1.htm Link to comment https://forums.phpfreaks.com/topic/20579-limiting-the-number-of-checkboxes-checked/#findComment-93994 Share on other sites More sharing options...
digitalgod Posted September 18, 2006 Author Share Posted September 18, 2006 thanks! but can you please tell me what's the php for though? Link to comment https://forums.phpfreaks.com/topic/20579-limiting-the-number-of-checkboxes-checked/#findComment-94071 Share on other sites More sharing options...
degsy Posted September 19, 2006 Share Posted September 19, 2006 Link 2 does. Maybe you should look at it ::) Link to comment https://forums.phpfreaks.com/topic/20579-limiting-the-number-of-checkboxes-checked/#findComment-94617 Share on other sites More sharing options...
digitalgod Posted September 19, 2006 Author Share Posted September 19, 2006 lol what I meant was, what does the php do in all of this, why does it check a db? Link to comment https://forums.phpfreaks.com/topic/20579-limiting-the-number-of-checkboxes-checked/#findComment-94814 Share on other sites More sharing options...
degsy Posted September 20, 2006 Share Posted September 20, 2006 It's a generic example. You take that part you need and work with it. Link to comment https://forums.phpfreaks.com/topic/20579-limiting-the-number-of-checkboxes-checked/#findComment-95199 Share on other sites More sharing options...
fenway Posted September 20, 2006 Share Posted September 20, 2006 The pseudo-code for the function should look like the following:-iterate through all form elements-check each element for trailing "[]"-iterate though the elements .length-count the times .checked is true-validate against "allowed" number Link to comment https://forums.phpfreaks.com/topic/20579-limiting-the-number-of-checkboxes-checked/#findComment-95258 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.