Welcome Guest, Not a member yet? Register   Sign In
Delete Selected Checkbox items from the database. HELP
#1

[eluser]basty_dread[/eluser]
How could I delete the selected checkbox with coresponding value from the database?
Anyone please help me. Thank you very much.

here is my code for the checkbox
i wonder how could i know the checked items and then Delete the items from the database
Code:
<form name="form1">
<?
for($i = 0; $i < sizeof($primeno); $i++){

?&gt;
&lt;input type="checkbox" name="rdindex1" value="&lt;?=$primeno[$i];?&gt;"/&gt;

&lt;?
}
?&gt;

&lt;input type="submit" name="delete" value="Delete Selected"&gt;
&lt;/form&gt;
#2

[eluser]basty_dread[/eluser]
Please help me on my problem. Thank you
#3

[eluser]bigtony[/eluser]
Change the input field name into an array:
Code:
// change this
&lt;input type="checkbox" name="rdindex1" value="&lt;?=$primeno[$i];?&gt;"/&gt;

// to this
&lt;input type="checkbox" name="rdindex1[]" value="&lt;?=$primeno[$i];?&gt;"/&gt;
Then when you read it in your controller the value passed back in $this->input->post('rdindex1') will be an array you can loop through.
#4

[eluser]basty_dread[/eluser]
thank's for posting bigtony how about checking if the checkbox is checked or not?
Thanks.
#5

[eluser]marjune[/eluser]
in the page where you submit, just make a loop to check the checked box

Code:
&lt;?
   for($i = 0; $i < sizeof($primeno); $i++){
      
      if(isset($primeno[$i]))
           //primeno[$i] is checked
   }
?&gt;
#6

[eluser]basty_dread[/eluser]
i can't get it on how to use javascript to check all or uncheck the checkboxes using this name with brackets

Code:
&lt;input type="checkbox" name="rdindex1[]" value="&lt;?=$primeno[$i];?&gt;"/&gt;

the javascript only works if the
Code:
name="rdindex1"

what should i do?
this is my javascript for checking all the checkbox:
Code:
function checkallBox()
{
    for (i=0;i<document.forms['formkeywords'].rdindex1.length;i++)
    {
        document.forms['formkeywords'].rdindex1[i].checked=true;
                                                                       }
}
#7

[eluser]bigtony[/eluser]
Why do you need to process it in JavaScript?
#8

[eluser]basty_dread[/eluser]
just like in yahoo mail. there is one checkbox that checked all the checkboxes. and when it uncheck the checkboxes... and when you press delete it will delete all the checked items.
#9

[eluser]bianchi[/eluser]
how about the controller and the model??




Theme © iAndrew 2016 - Forum software by © MyBB