how to switch to next question after clicking next button?












0















I have two issues
1) How to show the answer on clicking show Answer button
2) how to switch from one question to other on clicking next button
here is the screenshoot of output I am getting
getting question one beloow the other and answer is also showing without clicking show answer button



here is form html I have created which is woring perfectly fine



<label for="qnum">Select no.of questions:</label>
</div>
<div class = "col-75"><input type="number" id="qnum" name="que" value="1" min="1" max="100"></div>
<br /><br />
</div>
<br />

<div class="row">
<div class="col-25">
<label for="int">Select no. of Integers:</label></div>
<div class="col-75">
<select name="select" id="int">
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
<option value="6"> 6 </option>
<option value="7"> 7 </option>
<option value="8"> 8 </option>
<option value="9"> 9 </option>
<option value="10"> 10 </option>
</select>
</div>
</div>
<br />

<div class="row">
<div class="col-25">
<label for="dig">Select no. of digits:</label></div>
<div class="col-75">
<select name="digits" id="dig">
<option value="1"> 1 digit</option>
</select>
</div>
<br /><br /><br /><br />
</div>

<div class="row">
<div class="col-25"><label>Select operations:</label><br /></div>
<div class="col-75">
<input type="checkbox" id="mix" value="all" class="toggle-button"><label>All</label>
<input type="checkbox" id="add" name="operation" value="Addition" checked><label>Addition</label>
<input type="checkbox" id="sub" name="operation" value="Subtraction"><label>Subtraction</label>
<input type="checkbox" id="mult" name="operation" value="Multiplication"><label>Multiplication</label>
<input type="checkbox" id="div" name="operation" value="Division"><label>Division</label>
</div>
<br /><br />
<br /><br />
</div><br />


<input type="submit" name="submit" value="Generate" id = "gen"><br>
<input type="submit" name="play" value="Play" id="play">
<br /><br><br><br>

</form>
</div>

<script>
$( '.col-75 .toggle-button' ).click( function () {
$( '.col-75 input[type="checkbox"]' ).prop('checked', this.checked)
})
</script>


here the expressions are generating randomly which is perfectly fine for my purpose.
And here is my php code which is also woring perfectly fine
but in screenshot the input is given for only 2 questions thats whys its showing 2 questions but in my case there can bemany question depends on input given by user(max limit of questions is 100).
How can I do fix those 2 issues I have mentioned abobe?



//display sequence having only single digit numbers
if($_POST['digits'] == 1)
{
$q = $_POST['que'];
$previousInt = null; //Track the previous operand
$s = $_POST['select'];

for ($x = 1; $x<=$q; $x++) //for loop for no. of questions
{
$randomOperands = array();
$randomOperators = array();

// loop over $i n times
for ($i = 1; $i <=$s; $i++) //for loop for no. of integers user entered
{
$nextInt = rand(1, 9); // assign random operand to array slot
$randomOperands = $nextInt;
if($i < $s)
{
if($previousInt === 0) //No operator after last opearnd
{
//avoid division-by-zero
$randomOperators = $rOperators[rand(0, 2)];
}
else
{
$randomOperators = $rOperators[rand(0, $N-1)];
}
}
$previousInt = $nextInt;
}
// print array values
$exp = '';
$output_string = " ";
//Generating the expression
foreach($randomOperands as $key=>$value1)
{
$exp .= $value1 . "" ;
$output_string .= $value1. "<br>";
if(isset($randomOperators[$key]))
{
$exp .= $randomOperators[$key] ."";
$output_string .= $randomOperators[$key]."<br>";
}

}
//print expression
$res = eval("return ($exp);");//evaluate the expression


?><center> <?php echo ("This is Q(".$x."): <br>"), $output_string. "<br>________<br>";
?><br>
<input type="button" name="show" value="Show Answer"><?php echo $res."<br>"; ?><br>
<input type="button" name="next" value="Next" id="butn"><br><br>
</center>

<?php

}

}
}
?>


Please help me. How can I fix it ?










share|improve this question





























    0















    I have two issues
    1) How to show the answer on clicking show Answer button
    2) how to switch from one question to other on clicking next button
    here is the screenshoot of output I am getting
    getting question one beloow the other and answer is also showing without clicking show answer button



    here is form html I have created which is woring perfectly fine



    <label for="qnum">Select no.of questions:</label>
    </div>
    <div class = "col-75"><input type="number" id="qnum" name="que" value="1" min="1" max="100"></div>
    <br /><br />
    </div>
    <br />

    <div class="row">
    <div class="col-25">
    <label for="int">Select no. of Integers:</label></div>
    <div class="col-75">
    <select name="select" id="int">
    <option value="2"> 2 </option>
    <option value="3"> 3 </option>
    <option value="4"> 4 </option>
    <option value="5"> 5 </option>
    <option value="6"> 6 </option>
    <option value="7"> 7 </option>
    <option value="8"> 8 </option>
    <option value="9"> 9 </option>
    <option value="10"> 10 </option>
    </select>
    </div>
    </div>
    <br />

    <div class="row">
    <div class="col-25">
    <label for="dig">Select no. of digits:</label></div>
    <div class="col-75">
    <select name="digits" id="dig">
    <option value="1"> 1 digit</option>
    </select>
    </div>
    <br /><br /><br /><br />
    </div>

    <div class="row">
    <div class="col-25"><label>Select operations:</label><br /></div>
    <div class="col-75">
    <input type="checkbox" id="mix" value="all" class="toggle-button"><label>All</label>
    <input type="checkbox" id="add" name="operation" value="Addition" checked><label>Addition</label>
    <input type="checkbox" id="sub" name="operation" value="Subtraction"><label>Subtraction</label>
    <input type="checkbox" id="mult" name="operation" value="Multiplication"><label>Multiplication</label>
    <input type="checkbox" id="div" name="operation" value="Division"><label>Division</label>
    </div>
    <br /><br />
    <br /><br />
    </div><br />


    <input type="submit" name="submit" value="Generate" id = "gen"><br>
    <input type="submit" name="play" value="Play" id="play">
    <br /><br><br><br>

    </form>
    </div>

    <script>
    $( '.col-75 .toggle-button' ).click( function () {
    $( '.col-75 input[type="checkbox"]' ).prop('checked', this.checked)
    })
    </script>


    here the expressions are generating randomly which is perfectly fine for my purpose.
    And here is my php code which is also woring perfectly fine
    but in screenshot the input is given for only 2 questions thats whys its showing 2 questions but in my case there can bemany question depends on input given by user(max limit of questions is 100).
    How can I do fix those 2 issues I have mentioned abobe?



    //display sequence having only single digit numbers
    if($_POST['digits'] == 1)
    {
    $q = $_POST['que'];
    $previousInt = null; //Track the previous operand
    $s = $_POST['select'];

    for ($x = 1; $x<=$q; $x++) //for loop for no. of questions
    {
    $randomOperands = array();
    $randomOperators = array();

    // loop over $i n times
    for ($i = 1; $i <=$s; $i++) //for loop for no. of integers user entered
    {
    $nextInt = rand(1, 9); // assign random operand to array slot
    $randomOperands = $nextInt;
    if($i < $s)
    {
    if($previousInt === 0) //No operator after last opearnd
    {
    //avoid division-by-zero
    $randomOperators = $rOperators[rand(0, 2)];
    }
    else
    {
    $randomOperators = $rOperators[rand(0, $N-1)];
    }
    }
    $previousInt = $nextInt;
    }
    // print array values
    $exp = '';
    $output_string = " ";
    //Generating the expression
    foreach($randomOperands as $key=>$value1)
    {
    $exp .= $value1 . "" ;
    $output_string .= $value1. "<br>";
    if(isset($randomOperators[$key]))
    {
    $exp .= $randomOperators[$key] ."";
    $output_string .= $randomOperators[$key]."<br>";
    }

    }
    //print expression
    $res = eval("return ($exp);");//evaluate the expression


    ?><center> <?php echo ("This is Q(".$x."): <br>"), $output_string. "<br>________<br>";
    ?><br>
    <input type="button" name="show" value="Show Answer"><?php echo $res."<br>"; ?><br>
    <input type="button" name="next" value="Next" id="butn"><br><br>
    </center>

    <?php

    }

    }
    }
    ?>


    Please help me. How can I fix it ?










    share|improve this question



























      0












      0








      0








      I have two issues
      1) How to show the answer on clicking show Answer button
      2) how to switch from one question to other on clicking next button
      here is the screenshoot of output I am getting
      getting question one beloow the other and answer is also showing without clicking show answer button



      here is form html I have created which is woring perfectly fine



      <label for="qnum">Select no.of questions:</label>
      </div>
      <div class = "col-75"><input type="number" id="qnum" name="que" value="1" min="1" max="100"></div>
      <br /><br />
      </div>
      <br />

      <div class="row">
      <div class="col-25">
      <label for="int">Select no. of Integers:</label></div>
      <div class="col-75">
      <select name="select" id="int">
      <option value="2"> 2 </option>
      <option value="3"> 3 </option>
      <option value="4"> 4 </option>
      <option value="5"> 5 </option>
      <option value="6"> 6 </option>
      <option value="7"> 7 </option>
      <option value="8"> 8 </option>
      <option value="9"> 9 </option>
      <option value="10"> 10 </option>
      </select>
      </div>
      </div>
      <br />

      <div class="row">
      <div class="col-25">
      <label for="dig">Select no. of digits:</label></div>
      <div class="col-75">
      <select name="digits" id="dig">
      <option value="1"> 1 digit</option>
      </select>
      </div>
      <br /><br /><br /><br />
      </div>

      <div class="row">
      <div class="col-25"><label>Select operations:</label><br /></div>
      <div class="col-75">
      <input type="checkbox" id="mix" value="all" class="toggle-button"><label>All</label>
      <input type="checkbox" id="add" name="operation" value="Addition" checked><label>Addition</label>
      <input type="checkbox" id="sub" name="operation" value="Subtraction"><label>Subtraction</label>
      <input type="checkbox" id="mult" name="operation" value="Multiplication"><label>Multiplication</label>
      <input type="checkbox" id="div" name="operation" value="Division"><label>Division</label>
      </div>
      <br /><br />
      <br /><br />
      </div><br />


      <input type="submit" name="submit" value="Generate" id = "gen"><br>
      <input type="submit" name="play" value="Play" id="play">
      <br /><br><br><br>

      </form>
      </div>

      <script>
      $( '.col-75 .toggle-button' ).click( function () {
      $( '.col-75 input[type="checkbox"]' ).prop('checked', this.checked)
      })
      </script>


      here the expressions are generating randomly which is perfectly fine for my purpose.
      And here is my php code which is also woring perfectly fine
      but in screenshot the input is given for only 2 questions thats whys its showing 2 questions but in my case there can bemany question depends on input given by user(max limit of questions is 100).
      How can I do fix those 2 issues I have mentioned abobe?



      //display sequence having only single digit numbers
      if($_POST['digits'] == 1)
      {
      $q = $_POST['que'];
      $previousInt = null; //Track the previous operand
      $s = $_POST['select'];

      for ($x = 1; $x<=$q; $x++) //for loop for no. of questions
      {
      $randomOperands = array();
      $randomOperators = array();

      // loop over $i n times
      for ($i = 1; $i <=$s; $i++) //for loop for no. of integers user entered
      {
      $nextInt = rand(1, 9); // assign random operand to array slot
      $randomOperands = $nextInt;
      if($i < $s)
      {
      if($previousInt === 0) //No operator after last opearnd
      {
      //avoid division-by-zero
      $randomOperators = $rOperators[rand(0, 2)];
      }
      else
      {
      $randomOperators = $rOperators[rand(0, $N-1)];
      }
      }
      $previousInt = $nextInt;
      }
      // print array values
      $exp = '';
      $output_string = " ";
      //Generating the expression
      foreach($randomOperands as $key=>$value1)
      {
      $exp .= $value1 . "" ;
      $output_string .= $value1. "<br>";
      if(isset($randomOperators[$key]))
      {
      $exp .= $randomOperators[$key] ."";
      $output_string .= $randomOperators[$key]."<br>";
      }

      }
      //print expression
      $res = eval("return ($exp);");//evaluate the expression


      ?><center> <?php echo ("This is Q(".$x."): <br>"), $output_string. "<br>________<br>";
      ?><br>
      <input type="button" name="show" value="Show Answer"><?php echo $res."<br>"; ?><br>
      <input type="button" name="next" value="Next" id="butn"><br><br>
      </center>

      <?php

      }

      }
      }
      ?>


      Please help me. How can I fix it ?










      share|improve this question
















      I have two issues
      1) How to show the answer on clicking show Answer button
      2) how to switch from one question to other on clicking next button
      here is the screenshoot of output I am getting
      getting question one beloow the other and answer is also showing without clicking show answer button



      here is form html I have created which is woring perfectly fine



      <label for="qnum">Select no.of questions:</label>
      </div>
      <div class = "col-75"><input type="number" id="qnum" name="que" value="1" min="1" max="100"></div>
      <br /><br />
      </div>
      <br />

      <div class="row">
      <div class="col-25">
      <label for="int">Select no. of Integers:</label></div>
      <div class="col-75">
      <select name="select" id="int">
      <option value="2"> 2 </option>
      <option value="3"> 3 </option>
      <option value="4"> 4 </option>
      <option value="5"> 5 </option>
      <option value="6"> 6 </option>
      <option value="7"> 7 </option>
      <option value="8"> 8 </option>
      <option value="9"> 9 </option>
      <option value="10"> 10 </option>
      </select>
      </div>
      </div>
      <br />

      <div class="row">
      <div class="col-25">
      <label for="dig">Select no. of digits:</label></div>
      <div class="col-75">
      <select name="digits" id="dig">
      <option value="1"> 1 digit</option>
      </select>
      </div>
      <br /><br /><br /><br />
      </div>

      <div class="row">
      <div class="col-25"><label>Select operations:</label><br /></div>
      <div class="col-75">
      <input type="checkbox" id="mix" value="all" class="toggle-button"><label>All</label>
      <input type="checkbox" id="add" name="operation" value="Addition" checked><label>Addition</label>
      <input type="checkbox" id="sub" name="operation" value="Subtraction"><label>Subtraction</label>
      <input type="checkbox" id="mult" name="operation" value="Multiplication"><label>Multiplication</label>
      <input type="checkbox" id="div" name="operation" value="Division"><label>Division</label>
      </div>
      <br /><br />
      <br /><br />
      </div><br />


      <input type="submit" name="submit" value="Generate" id = "gen"><br>
      <input type="submit" name="play" value="Play" id="play">
      <br /><br><br><br>

      </form>
      </div>

      <script>
      $( '.col-75 .toggle-button' ).click( function () {
      $( '.col-75 input[type="checkbox"]' ).prop('checked', this.checked)
      })
      </script>


      here the expressions are generating randomly which is perfectly fine for my purpose.
      And here is my php code which is also woring perfectly fine
      but in screenshot the input is given for only 2 questions thats whys its showing 2 questions but in my case there can bemany question depends on input given by user(max limit of questions is 100).
      How can I do fix those 2 issues I have mentioned abobe?



      //display sequence having only single digit numbers
      if($_POST['digits'] == 1)
      {
      $q = $_POST['que'];
      $previousInt = null; //Track the previous operand
      $s = $_POST['select'];

      for ($x = 1; $x<=$q; $x++) //for loop for no. of questions
      {
      $randomOperands = array();
      $randomOperators = array();

      // loop over $i n times
      for ($i = 1; $i <=$s; $i++) //for loop for no. of integers user entered
      {
      $nextInt = rand(1, 9); // assign random operand to array slot
      $randomOperands = $nextInt;
      if($i < $s)
      {
      if($previousInt === 0) //No operator after last opearnd
      {
      //avoid division-by-zero
      $randomOperators = $rOperators[rand(0, 2)];
      }
      else
      {
      $randomOperators = $rOperators[rand(0, $N-1)];
      }
      }
      $previousInt = $nextInt;
      }
      // print array values
      $exp = '';
      $output_string = " ";
      //Generating the expression
      foreach($randomOperands as $key=>$value1)
      {
      $exp .= $value1 . "" ;
      $output_string .= $value1. "<br>";
      if(isset($randomOperators[$key]))
      {
      $exp .= $randomOperators[$key] ."";
      $output_string .= $randomOperators[$key]."<br>";
      }

      }
      //print expression
      $res = eval("return ($exp);");//evaluate the expression


      ?><center> <?php echo ("This is Q(".$x."): <br>"), $output_string. "<br>________<br>";
      ?><br>
      <input type="button" name="show" value="Show Answer"><?php echo $res."<br>"; ?><br>
      <input type="button" name="next" value="Next" id="butn"><br><br>
      </center>

      <?php

      }

      }
      }
      ?>


      Please help me. How can I fix it ?







      javascript php jquery html






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 10:47







      user10625430

















      asked Nov 21 '18 at 7:29









      user10625430user10625430

      507




      507
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407155%2fhow-to-switch-to-next-question-after-clicking-next-button%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53407155%2fhow-to-switch-to-next-question-after-clicking-next-button%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          鏡平學校

          ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

          Why https connections are so slow when debugging (stepping over) in Java?