I'm creating a form that will have several PHP variables which are pulled from a MySQL database. The problem I am having right now is that I cannot select or deselect all using JavaScript. I understand that PHP has to use JavaScript differently with the arrays, but I still wasn't able to make it work. My buttons are above the dynamically created part of the form.
<!--HTML CODE-->
<form name="creationForm" action="make_form.php" method="post">
<table width="700" border="1" bordercolor="#FFFFFF" cellpadding=6 cellspacing=0 bgcolor="#eeeeee" align="center">
<tr align="center">
<td><strong>Field Name</strong></td>
<td><strong>Description</strong></td>
<td><strong>Include in Form?<br>
<input type="button" value="Set All" name="set_in_form"
onClick="checkAll()">
<input type="button" value="Clear All" name="clear_in_form"
onClick="uncheckAll()"></strong></td>
<td><strong>Required Field?<br>
<input type="button" value="Set All" name="set_required"
onClick="checkAll()">
<input type="button" value="Clear All" name="clear_required"
onClick="uncheckAll()"></strong></td>
<td><strong>Set Fixed Value<br>(hidden field)</strong></td>
</tr>
<?
$connection = mysql_connect("localhost");
$db = "westhill";
mysql_select_db($db, $connection) or die( "Could not open $ db");
$sql = "SELECT * FROM container";
$result = mysql_query($sql, $connection) or die( "Could not execute sql: $sql");
$num_result = mysql_num_rows($result);
for ($i=0; $i <$num_result; $i++) {
$row = mysql_fetch_array($result);
echo "<form name=\"dynamic_form\" method=\"post\" action=\"make_form.php\">";
echo "<tr ><td>";
//start new form with field name label
echo $row["c_field_name"];
echo "</td><td>";
echo "<input type=\"textbox\" value=\"$row[c_field_name] \" size=\"15\" name=\"fd_array[]\">";
echo "</td><td align=\"center\">";
echo "<input type=\"hidden\" value=\"0\" name=\"in_form_chk[]\">";
echo "<input type=\"checkbox\" value=\"1\" name=\"in_form_chk[]\">";
echo "</td><td align=\"center\">";
echo "<input type=\"hidden\" value=\"0\" name=\"required_array[]\">";
echo "<input type=\"checkbox\" value=\"1\" name=\"required_array[]\">";
echo "</td><td>";
echo "<input type=\"checkbox\" value=\"1\" name=\"fixed_val_array[]\">
<input type=\"textbox\" size=\"15\" name=\"txt_fixed_val_array[]\">";
echo "</td><tr>";
}
//more php code below...
It seems like an easy task, but I can't get it to work. Any help would be greatly appreciated. Thanks!