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

  • Home
  • SEARCH
  • 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 9109739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:06:57+00:00 2026-06-17T03:06:57+00:00

I have a simple button in my <body> section of code: <p><button id=’submitstudents’>Submit Students</button></p>

  • 0

I have a simple button in my <body> section of code:

<p><button id='submitstudents'>Submit Students</button></p>

What I want the button to do is that if clicked on, it will go through the editvalidation() function to see if there are any errors, if there are no errors then it displays a confirmation box, if the user confirms then it should perform the ajax.

Problem is that when I click on the OK button in the confirmation box, nothing happens at all, page doesn’t even do any loading, my question is what is causing the page to not submit after clicking on the OK button in confirmation?

The is no errors in the error console.

Jquery code (in correct order displayed):

Validation:

function editvalidation()
{
    if ($("#sessionsDrop").val()==""){
        $("#studentAlert").html("Please Select an Assessment to edit from the Assessment Drop Down Menu");
    }
    if ($("#sessionsDrop").val()!="" && $("#studentadd").children().length==0){
        $("#studentAlert").html("You have not Selected any Students you wish to Add into Assessment");
    }
    if ($("#sessionsDrop").val()!="" && $("#studentadd").children().length!=0){
        return true;
    }
    return false;
}

submit form:

     function submitform() {    

        $.ajax({
            type: "POST",
            url: "updatestudentsession.php",
    data: { 
        sessionid:  $('#currentid').val(),
        students:   $('#addtextarea').val()
    },
            dataType:'json',  //get response as json
            success: function(result){
                        if(result.errorflag){

           //do your stuff on getting error message
          var newHtml="<span style='color: red'>"+result.msg+"</span>"; 
          $("#targetdiv").html(newHtml);  //i am displaying the error msg here

        }else{
           //you got success message

           var newHtml="<span style='color: green'>"+result.msg+"</span>"; 
                $("#targetdiv").html(newHtml);


               //append students you want to add to assessment into student exist select box 
               var selectedStudents = jQuery("select#studentadd").find("option");
                selectedStudents.appendTo($("select#studentexist"));
                $('option.red', 'select#studentexist').remove(); 

                 //blank #studentadd select box
                 $('#studentadd').empty(); 

                    $('#targetdiv').show();
            }
        }
      }); 
}

Confirmation:

         function showConfirm(){

          var examInput = document.getElementById('currentAssessment').value;

          if (editvalidation()) {

         var confirmMsg=confirm("Are you sure you want to add your selected Students to this Assessment:" + "\n" + "Exam: " + examInput);

         if (confirmMsg==true)
         {
         submitform();   
     }
  }
}

Button click:

$('body').on('click', '#submitstudents', showConfirm);  
  • 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-06-17T03:06:58+00:00Added an answer on June 17, 2026 at 3:06 am

    Try

    $('#submitstudents').click(function(){
        showConfirm();
    });
    

    EDIT:

    Your script should work. Put all the functions and handler for the click event inside $(document).ready(function(){ //Code goes here });.

    Also make sure the jquery library is linked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple JSP that contains checkbox and submit button: <form action=MappingSubmit.jsp enctype=multipart/form-data
I have this simple code that append a div inside the body, <!DOCTYPE html>
I have a simple Button control that contains an Image object as its content.
I have a simple submit button. I am wanting to align it to the
This is probably a basic html/css question... I have a simple one-button form that
I have a simple query tied to a command button that shows a summary
I have the simple JS code for updating text on button: <html> <head> <script
I have simple form with a textarea and a button, and I submit the
I have a simple webpage: <html> <body> When button has value of Start Clock
I have created a very simple user control ActiveX with a simple button that

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.