Tomatron Posted February 20, 2008 Share Posted February 20, 2008 Hi there Relatively new to php, started using it to send forms recently, having some trouble sending a collection of checkboxe. They have been created from a piece of javascript which unfortunatly give thm all the same name. so when an email is sent it only sends the last checkbox vreated, how would i get it to send all of the checkboxes? Many Thanks!! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 20, 2008 Share Posted February 20, 2008 If the script to send the email can handle a POST value that is an array, you can use square brackets in the checkbox name, like: <input type="checkbox" name="field1[]" value="1" /> 1 <input type="checkbox" name="field1[]" value="2" /> 2 <input type="checkbox" name="field1[]" value="3" /> 3 Otherwise, each checkbox will have to have it's own name <input type="checkbox" name="field1" /> 1 <input type="checkbox" name="field2" /> 2 <input type="checkbox" name="field3" /> 3 Either way, something will have to change on the form, it's not a PHP problem. Quote Link to comment Share on other sites More sharing options...
Tomatron Posted February 20, 2008 Author Share Posted February 20, 2008 ok changed a few bits so now the checkboxes when created are named starting from '0' up to watever numer of checkboxes is created, as its a different amount each time. how would i add all the check boxes present to an email? Thanks again! Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 20, 2008 Share Posted February 20, 2008 What script are you using to send the email? 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.