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 1101163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:59:39+00:00 2026-05-17T00:59:39+00:00

I have code that opens a dialog, validates, and posts a form when the

  • 0

I have code that opens a dialog, validates, and posts a form when the validation is successful.

If the user clicks “Cancel,” the dialog should reset until the next time it’s called.

If the user clicks “OK,” the dialog should close and the form should post, so if I hit the back button the dialog doesn’t appear on the page.

Code is as follows:

<script>    
$(function(){//document ready
      $("#dialog").dialog({
      autoOpen: false,
      modal: true
    });


  $("#confirmLink").click(function(e) {

    e.preventDefault();
    var targetUrl = $(this).attr("href");


    $("#dialog").dialog(

    { minWidth: 500 },{
      buttons : {

         "Ok": function() {

            $('#flagform').submit();


            //window.location.href="modalReceipt.asp?documentGUID="+$("#documentGUID").val()+"&fycuserid="+$("#fycuserid").val()+"&reason=" + $("#reason").val()+"&other="+ $("#other").val()
            },
        "Cancel" : function() {
          $(this).dialog("close");
        }
      },
      open: function() { 

    jQuery.validator.messages.required = "";

        $("#flagform").validate({
        invalidHandler: function(e, validator) {
            var errors = validator.numberOfInvalids();
            if (errors) {
                var message = errors == 1
                    ? 'You missed 1 field. It has been highlighted below'
                    : 'You missed ' + errors + ' fields.  They have been highlighted below';
                $("div.error span").html(message);
                $("div.error").show();
            } else {
                $("div.error").hide();
            }
        },
        // the errorPlacement has to take the table layout into account

        messages: {
            reason: "*",
            explanation: "*"
            },
    });//validate

        },

    });




    $("#dialog").dialog("open");
  });
    } );
</script>

</head>
<body>
    <a class="normal" id="confirmLink" href="">Test</a>
        <div id="dialog" title="Flag This Document" style="display:none">
            <form id="flagform" action="modalReceipt.asp" method="post">
      Please choose a reason for flagging this document and provide an explanation, if necessary.
  <p><p><div class="error" style="display:none;color:red">      <span></span>.<br clear="all"/>
</div>
 <table class="emptygrid">
<tr>
<td class="header">Reason:</td>
<td class="data">
    <select name="reason" id="reason" class="required">
        <option value="">-- Choose a Reason --</option>
        <option value="plagiarism">Plagiarism</option>
        <option value="submissionError">Submission Error</option>
        <option value="instructions">Student Didn't Follow Instructions</option>
        <option value="blankDocument">Blank Document</option>
        <option value="other">Other (please explain)</option>
      </select>


        </td>
        <td class="status"></td>

</tr>
<tr>
<td class="header" style="vertical-align:top">Explanation:</td>
<td class="data"> <textarea name="explanation" rows="10" cols="35"></textarea></td><td class="status"></td>

</tr>


</table>
<input type="hidden" id="fycuserid" name="fycuserid" value="33"/>
<input type="hidden" id="documentGUID" name="documentGUID" value="26219247-EB85-4ABD-8F74-C8448BA06472"/>

</form>
</div>
  • 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-17T00:59:40+00:00Added an answer on May 17, 2026 at 12:59 am

    If the user clicks “Cancel,” the
    dialog should reset until the next
    time it’s called.

    edit your “Cancel” to something like this,

    "Cancel": function() {
         $(this).dialog("close");
         $(this).find('form')[0].reset();
    }
    

    If the user clicks “OK,” the dialog should close and the form should post, so if I hit the back button the dialog doesn’t appear on the page.

    I suggest you do it on server-side. When submit is successful, do a cookie or session variables. Check that variable when page is loaded and do something for the dialog to appear or not appear in the page.

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

Sidebar

Related Questions

I have written code that opens 16 figures at once. Currently, they all open
Is there any way to have a code that opens a PDF file in
I have the following code that opens a new popup window while disabling the
I have some AS2 code that opens a SWF file through an HttpHandler. I'm
Android 2.1 via eclipse I have an activity that opens a dialog themed activity
I have the following code that determines if it's the first time the user
I have a dialog box in mvc that opens up first time but not
I have an HTML link that opens a jQuery modal dialog which contains an
I have a view with a button that opens a jquery dialog via partial
On my web page I have a button that opens a modal jQuery dialog.

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.