Welcome Guest, Not a member yet? Register   Sign In
Generating Checkboxes At Runtime
#1

[eluser]PowerCode[/eluser]
Hello Guys,

Here's the scenario. This is for an admin backend, wherein lets say I generate a list of blog posts I have. I need to have a checkbox after each of them, which I can mark and hit something like delete.

This would post a form, and I'll receive the id's of posts which were checked, so that I can perform additional actions on them, like deleting (Maybe having the name of checkbox as the post id). This could be possible if I can somehow set the checkboxes to a specific array in $_POST rather than directly into $_POST. This way, I can traverse the array and get things done quite easily.

This is similar to what we have in Wordpress. Can anyone point me in the right direction for something like this?
#2

[eluser]srisa[/eluser]
Code:
<input type="checkbox" name="deletes[]" value="<?php echo 'id of the blog post'?>" /> <?php echo 'blog post title'; ?>
When submit button is clicked $_POST['deletes'] will contain the values of all checked boxes.
#3

[eluser]PowerCode[/eluser]
Thanks for the quick reply! I now remember reading this in the manual, but for some reason I though CI didn't support it (though it has a dedicated section for it in the manual!).




Theme © iAndrew 2016 - Forum software by © MyBB