0

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>&nbsp;</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 &gt;&gt;" /></td>
        </tr>

      </table>
      <p>&nbsp;</p>

    </div>
  </form>
</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • I think you mix client side expectations and server side ability. you should look into AJAX. Where do you even call openForm? – mplungjan Jul 26 '22 at 05:43
  • you can do several things, 1. create all forms you want and hide them on click to next button make form visible , or add new form using jquery. – Aqib Javed Jul 26 '22 at 05:57

0 Answers0