Hi,
The default situiation for checkbox form element onsubmit, is to send
its value if it is checked, or not send any value at all and the server side
script does not catch its value or in other word, it does not feel with
its presence at all, if it it's not checked.
My question is:
How to change this default situiation?
i.e If checkbox is checked, send a value, and if it is NOT checked, send another value.
You may get a head with this problem if you look at the following Example:
Note: This example may need PHP server enabled to produce dynamic form elements.
<html>
<head>
<title>ToFormProcess</title>
</head>
<body>
<form action="form2.php" method="post">
<?
for ($i = 0; $i < 4; ++$i)
{
?>
<input type="text" name="txt[]">
<input type="text" name="txt1[]">
<input type="checkbox" value="yes<?=$i?>" name="chk[]" id="c<?=$i?>">
To Send this row check before submit <?=$i ?><br>
<?}
?>
<input type="submit">
</form>
</body>
</html>
The above code will produce a form with 4 rows of form elements, each row contain two text
fields and a check box
The serverside script interbreter, in our case here is PHP, will assign each element value
in an array of its name,i.e the first text field in the first row value will be $txt[0],
the second text field in the first row value will be $txt1[0] and the value of the check box
in the first row will be $chk[0]. HERE is the problem, i.e if the first checkbox does not checked
The $chk[0] will be assigned to the second checkbox.!?๐