Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get number back to 1 when going on a new page
    primarykey
    data
    text
    <p>I have a problem with my application. First of all on a previous page the teacher types in the number of sessions (exams) he or she wants to create and types in the number of questions they want per session.</p> <p>Now on the current page, If I have multiple sessions or exams in other words, then lets say I am on the first exam, it will let me add question numbers for the first exam. Now If I submit the form then it will take me to the second session and I have to add new question numbers in from scratch. Now if I try to add a question number a question number, then it does not add a question number into the table.</p> <p>I have figured out where the problem occurs. The problem occurs in the code below:</p> <pre><code>if (qnum &gt; &lt;?php echo (int)@$_POST['textQuestion']; ?&gt;) { return; } </code></pre> <p>What I have stated above is that if the number of questions added, is more than the number of questions stated on the previous page, then do not add question number. So lets say I have 2 sessions and I want only 1 question per session. In the first session it adds question number 1, but when I get to second session, it doesn't add question number 1 for second session because it thinks it is question number 2, even though it is suppose to be question 1 for second session. </p> <p>So how do I get it so that if user goes to second session, it knows that the question number starts back at 1?</p> <p>Below is full code on how question number is added into a table:</p> <pre><code> var qnum = 1; var count = 1; function insertQuestion(form) { if (qnum &gt; &lt;?php echo (int)@$_POST['textQuestion']; ?&gt;) { return; } var $tbody = $('#qandatbl &gt; tbody'); var $tr = $("&lt;tr class='optionAndAnswer' align='center'&gt;&lt;/tr&gt;"); var $qid = $("&lt;td class='qid'&gt;" + qnum + "&lt;/td&gt;"); $tr.append($qid); $tbody.append($tr); count++; $(form).find('.numberOfQuestions').val(qnum); ++qnum; $("#questionNum").text(qnum); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload