Based on the user selection I want to show the form elements.Here the user selects class1,class6,engg. How do I bring the all form element in one common form right know I am having different form and form field for class 1,6. I am struggling to solve this issue.I don't know How to fix this.
My questions Are:
- If user select class1 I have list class1 form?
- If User select class2 I have to combine class1 and class6 under one form.
- Like wise user select class1,class2,class6,engg. I want to make all the form elments under one form.
-
I have given my output sample?
My FORM
<form name="frm" method="post"> <table align="center"> <tr> <td>Name</td> <td><input type="text" name="txt" id="txt" required ></td><td></td> </tr> <tr> <td>Product</td> <td> <input type="checkbox" name="chk[]" value="class1">class1 <input type="checkbox" name="chk[]" value="class6">class6 <input type="checkbox" name="chk[]" value="class8">class8 <input type="checkbox" name="chk[]" value="class10">class10 <input type="checkbox" name="chk[]" value="class12">class12 <input type="checkbox" name="chk[]" value="engineering">engineering <input type="checkbox" name="chk[]" value="technology">technology </td><td></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="Save"></td><td></td> </tr> </table> </form>
My PHP VALUES
<?php
if (isset($_POST['submit']))
{
$name = $_POST['txt'];
$product = $_POST['chk'];
print_r($product);
foreach($product as $k=> $v)
{
if($v=="class1")
{
?>
<form name="f1" action="" method="post">
<p>class1
<input type="checkbox" name="chk[]" value="allsubject">allsubject
<input type="checkbox" name="chk[]" value="science">science
<input type="checkbox" name="chk[]" value="maths">maths
</p>
<input type="submit" name="submit" value="submit">
</form>
<?php
}
if($v=="class1" && $v="class6")
{
?>
<form name="f1" action="" method="post">
<p>class1</p>
<input type="checkbox" name="chk[]" value="allsubject">allsubject
<input type="checkbox" name="chk[]" value="science">science
<input type="checkbox" name="chk[]" value="maths">maths
<p>class6</p>
<input type="checkbox" name="chk[]" value="allsubject">allsubject
<input type="checkbox" name="chk[]" value="science">science
<input type="checkbox" name="chk[]" value="maths">maths
<input type="text" name="name" value="">Tutor Name
<input type="text" name="name" value="">Tutor Address
<input type="submit" name="submit" value="submit">
</form>
<?php
}
}
}
?>
**I want output like this:**For class1 form:
<form name="f1" action="" method="post">
<p>class1
<input type="checkbox" name="chk[]" value="allsubject">allsubject
<input type="checkbox" name="chk[]" value="science">science
<input type="checkbox" name="chk[]" value="maths">maths
</p>
<input type="submit" name="submit" value="submit">
</form>
****I want output like this:**For class1, class6 form:**
<form name="f1" action="" method="post">
<p>class1</p>
<input type="checkbox" name="chk[]" value="allsubject">allsubject
<input type="checkbox" name="chk[]" value="science">science
<input type="checkbox" name="chk[]" value="maths">maths
<p>class6</p>
<input type="checkbox" name="chk[]" value="allsubject">allsubject
<input type="checkbox" name="chk[]" value="science">science
<input type="checkbox" name="chk[]" value="maths">maths
<input type="text" name="name" value="">Tutor Name
<input type="text" name="name" value="">Tutor Address
<input type="submit" name="submit" value="submit">
</form>
Like this the I want to make the form base on user selection.If user selected the all three classes(1,6,8), class 1 has different subject,like wise class 6 is different subject and engg has different subject.Now many problem is if user picks class(1,6,8),like wise class(1,6). How do I combine all the form element under one form and has one submit button