Nat Posted April 16, 2007 Share Posted April 16, 2007 hi! Was wondering if anyone could help me with this problem. I have made a form consisting of an array of seven checkboxes. I'm trying to figure out how to write a php script to calculate 1 dollar for every checkbox chosen. Nat. Quote Link to comment Share on other sites More sharing options...
Hughesy1986 Posted April 16, 2007 Share Posted April 16, 2007 Have you got any code you can show us? Glen Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted April 16, 2007 Share Posted April 16, 2007 As Hughesy1986 suggested, seeing some of your code would be helpful, but for now let's assume you have a form looking somewhat like this: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <input type="checkbox" name="checkboxes[]" value="CheckBox 1"> <input type="checkbox" name="checkboxes[]" value="CheckBox 2"> <input type="checkbox" name="checkboxes[]" value="CheckBox 3"> <input type="checkbox" name="checkboxes[]" value="CheckBox 4"> <input type="checkbox" name="checkboxes[]" value="CheckBox 5"> <input type="checkbox" name="checkboxes[]" value="CheckBox 6"> <input type="checkbox" name="checkboxes[]" value="CheckBox 7"> <input type="submit" name="submit" value="Submit!"> </form> You could check how many checkboxes were checked simply by doing something like this: <?php if($_POST['submit']){ $boxes_checked = count($_POST['checkboxes']); echo 'You clicked '.$boxes_checked.' box(es). You get $'.$boxes_checked.'!'; } ?> Quote Link to comment Share on other sites More sharing options...
Nat Posted April 16, 2007 Author Share Posted April 16, 2007 Thank you so much 'HeyRay2'. You're a legend. You've solved my problem. 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.