Menu
I have two links at the moment, and one says [B]All[B]None
I would like to be able to click on [B]All[B]None
Any Help On This Topic?
[CODE]<SCRIPT type="text/JavaScript">
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "None"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "All"; }
}
// End -->
</script>[/CODE]
[code=html]
<input type=button value='All' onClick='this.value=check(this.form.list)'>[/code]
<i>
</i>function allCheckboxes(f, opt) {
with (f) {
var x, len = elements.length;
for (x=0; x<len; ++x) {
if (elements[x].type == "checkbox") {
elements[x].checked = opt;
}
}
}
return false;
}
[code=php]<SCRIPT type="text/JavaScript">
function allCheckboxes(f, opt) {
with (f) {
var x, len = elements.length;
for (x=0; x<len; ++x) {
if (elements[x].type == "checkbox") {
elements[x].checked = opt;
}
}
}
return true;
}
</script>
<?php
$rows = mysql_num_rows($result);
//Start the table
echo "<table align='center' width='50%' border='1' cellspacing='5' cellpadding='0'>n";
echo "<tr><td colspan='3'><input type='submit' value='Delete Selected'>n
</td>n
</tr>n";
//The Two Links
echo '<tr><td colspan="3">Select: <a href="javascript:void(0)" onclick="return allCheckboxes(document.formName, true)">All</a>
<a href="javascript:void(0)" onclick="return allCheckboxes(document.formName, false)">None</a> </td></tr>';
// loop to create table
for ($r = 1; $r <= $rows; $r++) {
echo "<tr>n";
// loop to create table columns
echo "<td width='20px'><input type='checkbox' name='formName' value='". $username = mysql_result($result, $r-1, 1) ."'></td>n";
for ($c = 1; $c <= mysql_num_fields($result);$c++) {
echo "<td>". mysql_result($result, $r-1, $c-1) ."</td>n";
} echo "</tr>n";
}
echo "<tr><td colspan='3'><input type='submit' value='Delete Selected'>n
</form>n
</td>n
</tr>n
</table>n";
} [/code]
[code=php]</script>
<?php
//echo "<table width ='50%' border = '1' cellspacing = '5' cellpadding = '0'>";
//$columns = 3;
$rows = mysql_num_rows($result);
echo "<table align='center' width='50%' border='1' cellspacing='5' cellpadding='0'>n";
// set variables from form input
//$rows = $_POST['rows'];
//$columns = $_POST['columns'];
// loop to create rows
echo "<tr><td colspan='3'><input type='submit' value='Delete Selected'>n
</td>n
</tr>n";
echo '<tr><td colspan="3">Select: <a href="javascript:void(0)" onclick="return allCheckboxes(document.formName, true)">All</a>
<a href="javascript:void(0)" onclick="return allCheckboxes(document.formName, false)">None</a> </td></tr>';
//The form
echo '<form name="formName" method="post" action="deletedir.php">';
for ($r = 1+1; $r <= $rows; $r++) {
echo "<tr>n";
// loop to create columns
echo "<td width='20px'><input type='checkbox' name='formName' value='". $username = mysql_result($result, $r-1, 1) ."'></td>n";
for ($c = 1; $c <= mysql_num_fields($result);$c++) {
echo "<td>". mysql_result($result, $r-1, $c-1) ."</td>n";
} echo "</tr>n";
}
echo "<tr><td colspan='3'><input type='submit' value='Delete Selected'>n
</form>n
</td>n
</tr>n
</table>n";
}
else{
//the session variable isn't registered, send them back to the login page
header( "Location: http://www.d-top.org/catolog/login.php" );
}
?>[/code]
If you are saying like this, it doesn't work[/QUOTE]
[b]formName[/b] is supposed to reference the [b]name[/b] attribute value of your FORM tag.[/QUOTE]
[code=html]<h2>Delete a Session</h2>
<form method="post" action="deletedir.php">
<SCRIPT type="text/JavaScript">
function allCheckboxes(f, opt) {
with (f) {
var x, len = elements.length;
for (x=0; x<len; ++x) {
if (elements[x].type == "checkbox") {
elements[x].checked = opt;
}
}
}
return true;
}
</script>
Click <a href="../checkLogin.php">here</a> to go back to the admin section.<form name="list" method="post" action="deletedir.php">
<table border='0' cellspacing='0' cellpadding='0'><tr><td bgcolor='#00AA33'>
<table align='left' border='0' cellspacing='1' cellpadding='3'>
<tr><td colspan='3' bgcolor='#FFFFFF'><input type='submit' value='Delete Selected'>
</td>
</tr>
<tr><th bgcolor="#FFFFFF">Select: <a href="javascript:void(0)" onclick="return allCheckboxes(document.list, true)">All</a>
<a href="javascript:void(0)" onclick="return allCheckboxes(document.list, false)">None</a></th>
<th bgcolor="#FFFFFF">User Name</th>
<th bgcolor="#FFFFFF">User ID</th>
</tr><tr>
<td width="20" bgcolor="#FFFFFF"><input type="checkbox" name="formName" value="8"></td><td bgcolor='#FFFFFF'>rat</td>
<td bgcolor='#FFFFFF'>8</td>
</tr>
<tr>
<td width="20" bgcolor="#FFFFFF"><input type="checkbox" name="formName" value="9"></td><td bgcolor='#FFFFFF'>ted</td>
<td bgcolor='#FFFFFF'>9</td>
</tr>
<tr><td colspan='3' bgcolor='#FFFFFF'><input type='submit' value='Delete Selected'>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
Click <a href='../checkLogin.php'>here</a> to go back to the admin section.[/code]
0.1.9 — BETA 5.16