
December 13th, 2003, 06:51 PM
|
|
Contributing User
|
|
Join Date: Apr 2003
Posts: 187
Time spent in forums: < 1 sec
Reputation Power: 6
|
|
|
problem with checkboxes and arrays
alright so I need to make checkboxes which can be all selected with one check box. The checkboxes are made with a while{ statement, so they are not definite. I had been using this:
PHP Code:
//where the info is processed
function deleteCom() {
$where = join(',', $_POST['deleteCom']);
$query = mysql_query("DELETE FROM comments WHERE comid IN ($where);") or die(mysql_error());
//header("Location: index.php?page=comments&userid=" . $_GET['userid']);
}
//the select all checkbox and jscript
<script language=javascript>
function checkUncheckAll(oCheckbox) {
var el, i = 0, bWhich = oCheckbox.checked, oForm = oCheckbox.form;
while (el = oForm[i++])
if (el.type == 'checkbox' && el.name.substr(0,9) == 'deleteCom') el.checked = bWhich;
} </script>
<p>
<input type='checkbox' id='checkAll' name='checkAll' onclick='checkUncheckAll(this);' title="Select or Deselect All Users">
<-- Select All
</p>
//i make the checkbox depending on security settings for user, and then it is echoed out...
$deleteBox = '<input name="deleteCom[]" type="checkbox" value="' . $comment['comid'] . '" title="Select Comment" />';
I tried this and when I click the select all box, only the first box is selected, and when I delete them, only the first message will be deleted! Why? It always worked before I thought.
thank you
__________________
hey it's the CHARKING
|