is there any way i can fix this?
if you save this code in a .php file and run it, tick a check box and it will add its value in the text box, but if you untick the checkbox it still adds the value in the text box, it should remove it not add it
you really have to see the code in action i guess to see what i mean :/.
thanks for you help in adv
Code: Select all
<?php<?php
function open($title)
{
echo '<table border="0" width="50%" style="border: 1 solid #000000" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" style="background-color: #0099FF; color: #FFFFFF; font-family: Tahoma; font-size: 12pt; letter-spacing: 1pt; vertical-align: 1; font-weight: bold; border-bottom-style: solid; border-bottom-width: 1">'.$title.' [+]</td>
</tr>
<tr>
<td width="100%" style="font-family: Verdana; font-size: 8pt; color: #000000; text-align: Left; margin-left: 4">';
}
function close_table()
{
echo '</td>
</tr>
</table>';
}
?>
<!--
<script type="text/javascript">
function checkAll()
{
oColl = document.getElementsByName("check[]");
for (i=0; i!=oColl.length; i++)
oColl[i].checked = "true";
}
</script>
<script language="Javascript" type="text/javascript">
<!--
function changeTextBox(form, newValue, name)
{
form.hidden.value = form.hidden.value + newValue;
}
//-->
</script>
<title>Check Boxs</title>
<form action="check_boxs.php" name="checkbox" method="post">
<?php
open("Check Boxs");
$num = 5;
for($x=1; $x<=$num; $x++)
{
echo " Check Box $x: <input type="checkbox" name="check$x" value="$x" onClick="changeTextBox(this.form, '$x|', 'check$x')" />\n<br />";
}
?>
<div align="right">
<input name="submit" type="submit" value="Submit ->">
</div><?php
close_table();
?>
<input type="text" name="hidden" value="">
</form>
<?php
if(isset($_POST[submit]))
{
echo "<br />";
open("Results");
$hidden = explode("|",$_POST[hidden]);
$array = array_unique($hidden);
for($r=0; $r<=count($array); $r++)
{
if(!empty($array[$r]))
{
echo "Check Box $r: ".$array[$r]."<br />";
}
}
close_table();
}
?>
?>