Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7500201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:06:12+00:00 2026-05-29T20:06:12+00:00

I have an application here When you open the application, please keep clicking on

  • 0

I have an application here

When you open the application, please keep clicking on the “Add Question” button, you will realise that it would not let you add more than 5 table rows. This is because of this code here:

    if (qnum > 5) {
    return;
}

This line of code goes into the function below which controls adding table rows:

var qnum = 1;

function insertQuestion(form) {   


    if (qnum > 5) {
    return;
}


    var $tbody = $('#qandatbl > tbody'); 
    var $tr = $("<tr class='optionAndAnswer' align='center'></tr>");
    var $qid = $("<td class='qid'>" + qnum + "</td>");


    $tr.append($qid);
    $tbody.append($tr); 


    $(form).find('.numberOfQuestions').val(qnum);

    ++qnum;
    $("#questionNum").text(qnum);
    form.questionText.value = "";


}

The added rows go into this table here:

<table id="qandatbl" align="center">
<thead>
<tr>
    <th class="qid">Question No</th>
</tr>
</thead>
<tbody></tbody>
</table>

My question is that I am going to create a new function which is known as validation() function and this will create the alerts. What my question is that how do I write the if statement to state that if the last question number is not in a table row then display in the alert “You have not added all of your questions\n you have ” questions remaining”. How do I write the if statement?

Below is the current validation() function at moment:

function validation() {

    var marks = parseInt($("#total-weight").text());    
    var _qid = "";
    var _msg = "";

    var maxQuestions = <?php echo (int)@$_POST['textQuestion']; ?>;
    var questionsAdded = $('tr.optionAndAnswer').length;


    var alertValidation = "";
    // Note, this is just so it's declared...
    $("tr.optionAndAnswer").each(function() {


        _qid = $("td.qid",this).text();
        _msg = "You have errors on Question Number: " + _qid + "\n";

        $(".textAreaQuestion",this).each(function() {



            if (!this.value || this.value.length < 5) {
                alertValidation += "\n\u2022 You have not entered a valid Question\n";
            }

            if (alertValidation != "") {
                return false; //Stop the each loop 
            }
        });

        $(".numberAnswerTxtRow",this).each(function() {


            var currenttotal = $(this).closest('.optionAndAnswer').find('.answerBtnsOn').length;

            if (!this.value) {
                alertValidation += "\n\u2022 Please Enter in the Number of Answers you Require for this question\n";
            }

            else if (currenttotal > $(this).val()){
                alertValidation += "\n\u2022You have selected more answers than the required amount\n";
    }

            else if (currenttotal < $(this).val()) {
                alertValidation += "\n\u2022 You have selected less answers than the required amount\n";
    }

            if (alertValidation != "") {
                return false; //Stop the each loop 
            }

        });

        $(".txtWeightRow",this).each(function() {


            if (!this.value) {
                alertValidation += "\n\u2022 Please enter in a figure for Number of Marks for this Question\n";
            }

            if (alertValidation != "") {
                return false; //Stop the each loop 
            }
        });


        if(alertValidation != ""){
            return false;
        }
    });

if(alertValidation == ""){      
            if($("#total-weight").text() < '0')
{
    _msg = '';
 alertValidation = "Your Total Session Marks Remaining does not equal 0 \n\n\u2022 You Need To Remove " + Math.abs(marks) +  " Marks";   
}

        else if($("#total-weight").text() > '0')
{
    _msg = '';
 alertValidation = "Your Total Session Marks Remaining does not equal 0 \n\n\u2022 You Have " + marks +  " Marks Remaining";   
}

        else if(questionsAdded  < maxQuestions){
    msg = '';
     alertValidation("You Have Not Added in All of Your Questions. You have " + (maxQuestions - questionsAdded) + " Questions Remaining:" );
}


}

    if (alertValidation != "") {
        alert(_msg + alertValidation);
        return false;
    }

    return true;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:06:13+00:00Added an answer on May 29, 2026 at 8:06 pm

    You can check for the no. of rows added and comapre against whatever max number you have. Try this.

    var maxQuestions = 5;
    var questionsAdded = $('tr.optionAndAnswer').length;
    if(questionsAdded  < maxQuestions){
         alert("Questions remaining: " + (maxQuestions - questionsAdded));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application here . When you open the application then please type
I have an application you can access here When you open the app, please
Here is my situation: I have an application that use a configuration file. The
here is a good question: I have an application compiled for iPhone OS 2.21.
Here's the core problem: I have a .NET application that is using COM interop
I have a question here regarding iPhone app submission. I have a free application
Here's my first question at SO. I have a internal application for my company
Here is my situation, I have an ESRI Map Silverlight application that needs to
I want to make application that when press the button it will make each
I have web application in that I have a ajaxTabedinterface. I want open the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.