delete-account-pleas Posted June 25, 2015 Share Posted June 25, 2015 (edited) Hey all I need to retrieve the check-box value which are checked in an array. My html code: <th><span class="title_box">Category name</span></th> </tr> </thead> <tbody> <tr> <td><input type="checkbox" name="catBox[]" class="groupBox" id="catBox_3" value="3" checked="checked" /></td> <td><label for="catBox_3">Women</label></td> </tr> <tr> <td><input type="checkbox" name="catBox[]" class="groupBox" id="catBox_12" value="12" checked="checked" /></td> <td><label for="catBox_12">Male</label></td> </tr> <tr> <td><input type="checkbox" name="catBox[]" class="groupBox" id="catBox_13" value="13" checked="checked" /></td> <td><label for="catBox_13">Kids</label></td> </tr> </tbody> </table> Using the following PHP code: Tools::getValue('catBox[]') Does not return any data for some reason? Solution: (use the right way to call a variable) Tools::getValue('catBox') Edited July 5, 2015 by Crezzur (see edit history) Link to comment Share on other sites More sharing options...
Wery Nguyen Posted June 26, 2015 Share Posted June 26, 2015 Hi Crezzur, I think you should use this instead: $catBoxes = Tools::getValue('catBox'); It will return an array of value: foreach ($catBoxes as $cb) { // do smth } Hope this help. 1 Link to comment Share on other sites More sharing options...
delete-account-pleas Posted July 5, 2015 Author Share Posted July 5, 2015 Hi Crezzur, I think you should use this instead: $catBoxes = Tools::getValue('catBox'); It will return an array of value: foreach ($catBoxes as $cb) { // do smth } Hope this help. Made a mistake with the Tools::getValue i used "Tools::getValue('catBox[]');" instead of "Tools::getValue('catBox');" Did not see it earlier until you made you post so thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now