根据用户选择,我想显示表单元素。用户选择class1,class6,engg.how我是否将所有表单元素放在一个通用表单中就知道我有不同的表格为1,6级如果用户选择了所有三个类(1,6,8),则第1类具有不同的主题,类似于明智的第6类是不同的主题,并且engg具有不同的主题。现在我想在一个下显示所有表单元素基于表单的一个用户选择。用户wish.user选择class1表示我必须显示class1表单。到目前为止我已经完成了。我的htmlform,我的phpvalues,我使用过array_intersect.now很多问题是如果用户选择类(1,6,8)如何将所有表单元素放在一个表单下并有一个提交按钮。
<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>Password</td>
<td><input type="password" name="pass" id="pass" 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>
My PHP VALUES
<?php
if (isset($_POST['submit']))
{
$name = $_POST['txt'];
$pass = $_POST['pass'];
$product = $_POST['chk'];
$class1SubjectFormValues = array('class1', 'class6', 'class8', ... );
$class12SubjectFormValues = array('class10', 'class12', 'class8','eng' );
if (array_intersect($product, $class1SubjectFormValues)) {
// class1 subject form
}
if (array_intersect($product, $class12SubjectFormValues)) {
// class12 subject form
}
?>
**Here is my class1 form**
<p>class1 subject form</p>
<form name="f1" action="" method="post">
<input type="checkbox" name="chk[]" value="allsubject">allsubject
<input type="checkbox" name="chk[]" value="science">science
<input type="checkbox" name="chk[]" value="maths">maths
</form>
</p>
**Here is my class6 form**
<p>class1 subject form</p>
<form name="f1" action="" method="post">
<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
</form>
</p>
**Here is my engg form**
<p>class1 subject form</p>
<form name="f1" action="" method="post">
<input type="checkbox" name="chk[]" value="allsubject">csc
<input type="checkbox" name="chk[]" value="science">IT
<input type="checkbox" name="chk[]" value="maths">maths
<input type="text" name="name" value="">Tutor Name
<input type="text" name="name" value="">Tutor Address
</form>
</p>
我想要这样的输出:
<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>
<p>class6
<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
</p>
<p>class 8</p>
<input type="checkbox" name="chk[]" value="allsubject">csc
<input type="checkbox" name="chk[]" value="science">IT
<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">
</form>