here is my form in which there are 4 checkboxes for 4 operations.
<form action="" method="POST">
Select no.of questions:<input type="number" name="que" value="que">
<br> <br>
Select no. of series: <select name="select_box">
<option value="0">Please Select</option>
<option value="1"> 2 </option>
<option value="2"> 3 </option>
</select>
<br><br>
Select number type(in digits) <input type="number" name="digits"
value="digits">
<br><br>
Select operations:<br />
<input type="checkbox" id="add" name="operation" value="addition"
id="add"><label>Addition</label>
<br/>
<input type="checkbox" id="sub" name="operation" value="substraction"
id="sub"><label>substraction</label><br/>
<input type="checkbox" id="add" name="operation" value="multiplication"
id="mul"><label>Multiplication</label><br/>
<input type="checkbox" id="add" name="operation" value="division"
id="div"><label>Division</label><br/><br / >
<br><br>
<input type="submit" name="submit" value="Generate"><br>
<br>
</form>
now how can i bind the respective event to respective checkbox (ex.If user click on addition then then only addition will perform) and in case user select 2 checkboxes at a time suppose add and subtract then only those two operation will have to perform ?
here is my php code where I am doing the rest code
<?php
//for 1 digits
if($_POST['digits'] == 1)
{
$que = $_POST['que'];
for ($x = 1; $x <=$que; $x++)
{
$rand1 = rand(0,9);
$rand2 = rand(0,9);
$rand3 = rand(0,9);
$operator = array('+', '-','*','/');
$randoperator = $operator[rand(0,3)];
switch ($randoperator) {
case "+":
$finalvalue = $rand1 + $rand2 + $rand3;
break;
case "-":
$finalvalue = $rand1 - $rand2 - $rand3;
break;
case "*":
$finalvalue = $rand1 * $rand2 * $rand3;
break;
case "/":
$finalvalue = $rand1 / $rand2 / $rand3;
break;
}
echo ("This is Q(".$x."):"), $rand1 . $randoperator . $rand2 .
$randoperator . $rand3 . '=' . $finalvalue ,'<br /><br />';
}
}
elseif(isset($_POST['digits']) == 2)
{
$qu = $_POST['que'];
for ($y = 1; $y <=$qu; $y++)
{
$rand1 = rand(10, 99);
$rand2 = rand(10, 99);
$rand3 = rand(10, 99);
$operator2 = array('+', '-','*','/');
$randoperator2 = $operator2[rand(0, 3)];
switch ($randoperator2) {
case "+":
$finalvalue2 = $rand1 + $rand2 + $rand3;
break;
case "-":
$finalvalue2 = $rand1 - $rand2 - $rand3;
break;
case "*":
$finalvalue2 = $rand1 * $rand2 * $rand3;
break;
case "/":
$finalvalue2 = $rand1 / $rand2 / $rand3;
break;
}
echo ("This is Q(".$y."):"), $rand1 . $randoperator2 . $rand2 .
$randoperator2 . $rand3 . '=' . $finalvalue2 ,'<br /><br />';
}
}
elseif(isset($_POST['digits']) == 3)
{
$q = $_POST['que'];
for ($p = 1; $p <=$q; $p++)
{
$rand1 = rand(100,999);
$rand2 = rand(100,999);
$rand3 = rand(100,999);
$operator3 = array('+', '-','*','/');
$randoperator3 = $operator3[rand(0,3)];
switch ($randoperator3) {
case "+":
$finalvalue3 = $rand1 + $rand2 +$rand3;
break;
case "-":
$finalvalue3 = $rand1 - $rand2 - $rand3;
break;
case "*":
$finalvalue3 = $rand1 * $rand2 * $rand3;
break;
case "/":
$finalvalue3 = $rand1 / $rand2 / $rand3;
break;
}
echo ("This is Q(".$p."):"), $rand1 . $operator3 . $rand2 . $operator3 .
$rand3 . '=' . $finalvalue3 ,'<br /><br />';
}
}
else{
//invalid;
}
?>
I am beginner in php ,how can I do the checkbox event that suggested in the answer for this code ?