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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:34:17+00:00 2026-06-15T00:34:17+00:00

I have a form that after the user sends his message by submit button,

  • 0

I have a form that after the user sends his message by submit button, gives a ‘success sending’ message.

But after a second the original page with the form is showing again
because submit makes the page refresh.

The code is:

<label id="success" style="visibility:   hidden">Your request has been sent successfully</label>
<form method="post" id="messege" onsubmit="return checkAnswer()" style="font-size: medium; margin-top: 10%" dir="rtl">
<div class="clear"></div>
        <div class="content_item">


            <br><br>
          <div style="width:170px; float: right;">name</div>
          <div style="width:430px; float:left;"><p><input class="contact" type="text" id="your_name" value="" /></p></div>
            <br><br><br><br><br>
          <div style="width:170px; float:right;">email</div>
          <div style="width:430px; float:left;"><p><input class="contact" type="text" id="your_email" value="" /></p></div>
            <br><br><br>
          <div style="width:170px; float:right;">the messege</div>
          <div style="width:430px; float:left;"><p><textarea class="contact textarea" rows="8" cols="50" id="your_message"></textarea></p></div>
          <br style="clear:both;" />
</div>
</form> 

The javascript function is:

<script type="text/javascript">

    function checkAnswer() {
        var name = document.getElementById("your_name").value;
        if (name == "") {
            alert("!!! insert name");
            return false;
        }
        var email = document.getElementById("your_email").value;
        if (email == "") {
            alert("!!! insert mail");
            return false;
        }
        var message = document.getElementById("your_message").value;
        if (message == "") {
            alert("!!! insert massege");
            return false;
        }
        var ans = parseInt(document.getElementById("user_answer").value);
        if (ans != 12) {
            alert("!!! wrong answer");
            return false;
        }
        else {
            document.getElementById("success").style.visibility = 'visible';
            document.getElementById("messege").style.visibility = 'hidden';

            return true;
        }

    }

And the asp.net code is:

@{
    var db = Database.Open("MyProjectSite");

    var name="";
    var email="";
    var message="";
    var answer="";

     if(IsPost)
    {
        name=Request.Form["your_name"];
        email=Request.Form["your_email"];
        message=Request.Form["your_message"];
       var insertMessege="INSERT INTO messegesFromCustomers(name,email,content,isCustomer)"+"VALUES (@0,@1,@2,@3)";
       db.Execute(insertMessege,name,email,message,"לא");
       db.Close();
    }

}

When I set the visible property of the success message to:”visible” with javascript,
how could I prevent the refreshing of the page?

The refresh erases my success message too.

Thanks

  • 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-15T00:34:19+00:00Added an answer on June 15, 2026 at 12:34 am

    In your case, the easiest way to work this function in is to add a url flag to signify the successful submission, then on page load check for it and display the confirmation message then, not before the page is submitted as the state of that is not saved (as you are seeing)

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

Sidebar

Related Questions

I have a form in an HTM page that, after pressing the submit button,
I have a form that and after the user fills in this form, I
I have a page that sends the user's browser a session cookie after login.
Hi I have a Sticky form that after successful completion I want to clear
I have a form that is closed unexpectedly immediately after showing it. I hooked
I currently have form that checks if a user has unsubmitted changes when they
I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN
I have a form. This form will submit data to 2 different pages. After
Currently I have a custom form login page in Spring Security 3 that sends
I have a form: <%= form_for(@message) do |f| %> That's located in my groups#show

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.