Home How do I properly display a confirmation message after a user submits a POST on a form
Reply: 0

How do I properly display a confirmation message after a user submits a POST on a form

user1790
1#
user1790 Published in April 25, 2018, 8:23 am

So I think i understand why this problem is happening. When i click on the submit button to submit the form, the page runs my click listener which sets the display of my message to initial. It is already at none in css. But as you can see i have code that should wait for the page to reload before that happens. But it still activates when i press submit. I already tried running the function Confirmation() in my $(document).ready but this does not change anything So after a press submit, the message displays, but then the page is reloaded after that which sets the the message back to Display: none; So to clarify, I want to display a confirmation message after a user submits the form. The messages starts at Display: none;, then javascript should be able to set it back to initial after the submit button is pressed and the page reloads with the message. (and i dont want to use AJAX) I use razor to capture the information from the form. Im working in VS empty webapp

let confirm = $('#confirm')

$(document).ready(function () {
    Contact();
    Local();
    Local2();
    console.log("onload");
})

function Confirmation() {
    $('#submit').on("click", function () {
        if (confirm.css('display') == 'none') {
            $(document).ready(function() {
                confirm.css('display', 'initial');
                console.log("submit");
            })            
        }
    });
};

Confirmation();


#confirm {
    display: none;
}


<fieldset id="confirm">
  <p>Name: @names</p>
  <p>Email: @emails</p>
  <p>@confirm</p>
</fieldset>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.387796 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO