I am trying to pop up a new form on the same page when the button named ""Next" is clicked. My code is shown below.
When the next button is clicked,a new web page(yes_no2.php) with a form is directed. But I expect a new form to be created in same page, when the button is clicked after selecting "YES" ,"No" in the current form.
function openForm() {
document.getElementById("myForm").style.display = "block";
}
function closeForm() {
document.getElementById("myForm").style.display = "none";
}
<div class="form-popup" id="myForm">
<form action="" method="post">
<div align="center">
<p> </p>
<table width="546" height="115" border="1">
<tr>
<?php
if(isset($_POST['next'])){
@$checkbox_yes = $_POST['checkbox_yes'];
@$checkbox_no = $_POST['checkbox_no'];
if(!$checkbox_yes and !$checkbox_no){
?>
<script>
alert("Please make Selection!");
</script>
<?php
}
else{
header("location:yes_no2.php"); }
}
?>
<td width="105">Question : </td>
<td width="234">
<?php echo $rows['q1']; ?>
</td>
<td width="79">
<p>Yes
</p>
<p>
<input type="checkbox" name="checkbox_yes" id="checkbox" />
</p>
</td>
<td width="100">
<p> No
</p>
<p>
<input type="checkbox" name="checkbox_no" id="checkbox2" />
</p>
</td>
</tr>
<tr>
<td>Answer: </td>
<td colspan="3"><input type="submit" name="next" id="next" value="Next >>" /></td>
</tr>
</table>
<p> </p>
</div>
</form>
</div>