Note that there are some explanatory texts on larger screens.

plurals
  1. POincorrect alert is being displayed
    primarykey
    data
    text
    <p>I have a problem with my application which is <a href="http://helios.hud.ac.uk/u0867587/testing/Testpage.php" rel="nofollow">here</a>. Please follow steps below:</p> <ol> <li><p>When you open the application, click on "Open Grid" and select option 4. Buttons A, B, C and D will appear below.</p></li> <li><p>In the Number of Answers textbox, type in the number 1. Then click on 1 button out of A, B, C or D (The button selected will turn green). When you have done that then click on the "Add Question" button.</p></li> <li><p>As you can see the details you have entered on top will be dispayed in a new row underneath. In the new row you have added, in the textbox under the "Number of Answers" column, change the number 1 to 2. Now click on the "Submit Details" button below.</p></li> </ol> <p>An alert should appear which states "you have selected less answers than the required amount". This is correct as in the textbox you stated you wanted "2" number of answers but under the "Answer" column you have selected only 1 answer (the button which has turned green).</p> <p>The problem is when you follow the next couple of steps.</p> <ol> <li><p>Click on the "Add Question" button again so that you have added a second row containing the details on top.</p></li> <li><p>In the second row you have added change the value in the textbox under the "Number of Answers" textbox from 1 to 3 and select 3 answers from buttons A, B ,C or D (3 buttons have to turn green).</p></li> <li><p>Now click on the "Submit Details" button. This time the alert appears showing two messages stating that "you have selected more answers than the required amount".</p></li> </ol> <p>This is completly wrong because in the first row, you have selected less answers than the amount stated and in the second row you have selected the right amount of buttons, so it should come up with an alert stating "you have selected less answers than the required amount" as this is true for the first row.</p> <p>My Question:</p> <p>Why is it showing this wierd alert and why are 2 messages apppearing when it should be 1 message in the alert?. Also If there is a mistake in multiple rows then I ant only an alert to appear for the top row. When that is fixed I want then an alert for the next row row and so on.</p> <p>Below is the relevant validation code (I believe the problem is the var context as I think the variable is wrong but I am not sure):</p> <pre><code> function validation() { var context = $('#qandatbl'); var currenttotal = context.find('.answerBtnsOn').length; alertValidation= ""; // Note, this is just so it's declared... $(".numberAnswerTxtRow").each(function() { if (!this.value) { alertValidation += "\nPlease Enter in the Number of Answers you Require for this question\n"; } else if (currenttotal &gt; $(this).val()){ alertValidation += "\nYou have selected more answers than the required amount\n"; } else if (currenttotal &lt; $(this).val()) { alertValidation += "\nYou have selected less answers than the required amount\n"; } }); if(alertValidation != "") { alert(alertValidation); return false; } </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.
 

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