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. Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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 ::) Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.