Jump to content

Can I use javascript to submit a form without reloading it?


Recommended Posts

I would like to save the content on a details page automatically without reloading the page. Is this possible?

I know that I can use

document.getElementById("caspioform").submit();

to submit the form. On the "Destination and triggers" page I can choose "Same Form", but this means that the details page will load again. I don't want this for various reasons, some of them discussed here:

 

http://forums.caspio.com/index.php/topic/3675-automatic-update/

I would extremely grateful if anybody can suggest a solution to this.

Thanks!

/Bjorn

Link to comment
Share on other sites

  • 8 years later...

I know this is very old, but it came up in a Google search for a topic similar to what I do.  I submit forms all the time without leaving the page.  I like to turn my Caspio forms into an instant storing off values as field change or after they stop typing for a textarea.

In short, without going into extreme detail (which it would take and perhaps MayMusic understands this and can take the time), I do this:

1) create a hidden iFrame in the footer of the form

2) I use jQuery and when a field has changed (or after a delay of change for the textarea), I get the value and the field NAME that has changed.

3) With the value and fieldname, I create a URL for the iFrame that sends both the fieldname and the value to the very same form you already have loaded.

4) Scripts on the form look for the incoming fieldname and value.  If it see those, it will change the current value for that field and then submit the form in the hidden frame.

Do remember to hide the Submit button and don't use Caspio's default submit functions.  You will also start an eternal loop of submissions to this hidden form unless you make a test.  I end up first testing to see if the value of the field desiring an update matches the existing value or not.  If it doesn't, then submit.  If it matches the existing value, you may have submitted the form already.  

This is a little heavier in data and time.  Large forms and slow internet can be a little more challenging, but all of my forms are now auto-submit to hidden forms as changes are made.  Nobody complains.  This is more common on the Internet today.  People are used to it.  Caspio should make it a feature.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...