0

I am trying to allow for a form to call a java script function without losing javascript dependent data on the page.

This is what I got.

The function is some generic appending function.

I lose of the appended data whenever I change the input string.

I added

        window.onbeforeunload = function(){
            return false;
        }

And it would work as long as I pressed no on all of the popup boxes.

Thank you

Edit: I ahve noticed that it happens wehenever the url name is changed

here is html for good measure

    <form method="get" action="#">
      <input type="text" id="data" name="post" placeholder="thoughts?" />
      <button onclick="appendToBody()">
        Post
      </button>
    </form>
5
  • can you provide html code also? Commented Jul 2, 2013 at 2:04
  • You need to use AJAX to send the form data to the server. Commented Jul 2, 2013 at 2:04
  • Not using any backend Commented Jul 2, 2013 at 2:04
  • The html code is just a div of the specified name, I am not sure how it is relevant! Commented Jul 2, 2013 at 2:05
  • I don't get it. Every time you reload you page submiting a form - you lose your javascript data - it's normall. Maybe you need $('form').submit(function() {});? Commented Jul 2, 2013 at 2:12

1 Answer 1

1

returning false in the forms onsubmit will stop the submit action.

  <form onsubmit="calltoyourfunction;return false">
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.