Jump to content
  • 0

Submit form go back in history on submission


DesiLogi

Question

I'm have a submission form that uses custom buttons (because of the need to show/hide Submit due to Rules) to do the Submit. I need, after submitting the new record, for the destination to go back in History a page (or two if the submit refresh logs the form as a page in History). 

I can't get the code to run in the Destinations wizard, using Message and html editor disabled. Here's what I have so far: basically the data submits correctly and a new record is created but I get no redirection to previous url. 

<SCRIPT LANGUAGE="JavaScript">
function goBack() {
    window.history.go(-1);
}
document.getElementById("caspioform").onsubmit = goBack;
</script>

The other option I tried was to put the js in the html block with the custom button for Submit. It does run the 'go back' code but the new record doesn't actually get submitted. So it's either the 1st choice with record submitted and no back-redirect or the 2nd choice with no record submitted and back-redirect working. 

If someone could clarify how to get the actual 'submit' AND the 'back-redirect' to work that'd be really great. Here's the custom button code in the html block, if that helps: 

<div style="text-align: center;"><input class="cb_custom_btn" type="submit" onclick="goBack()" value="SUBMIT" />
<SCRIPT LANGUAGE="JavaScript">
function goBack() {
    window.history.go();
}
document.getElementById("caspioform").onsubmit = goBack;
</script>
</div>

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
21 hours ago, DesiLogi said:

I'm have a submission form that uses custom buttons (because of the need to show/hide Submit due to Rules) to do the Submit. I need, after submitting the new record, for the destination to go back in History a page (or two if the submit refresh logs the form as a page in History). 

I can't get the code to run in the Destinations wizard, using Message and html editor disabled. Here's what I have so far: basically the data submits correctly and a new record is created but I get no redirection to previous url. 


<SCRIPT LANGUAGE="JavaScript">
function goBack() {
    window.history.go(-1);
}
document.getElementById("caspioform").onsubmit = goBack;
</script>

The other option I tried was to put the js in the html block with the custom button for Submit. It does run the 'go back' code but the new record doesn't actually get submitted. So it's either the 1st choice with record submitted and no back-redirect or the 2nd choice with no record submitted and back-redirect working. 

If someone could clarify how to get the actual 'submit' AND the 'back-redirect' to work that'd be really great. Here's the custom button code in the html block, if that helps: 


<div style="text-align: center;"><input class="cb_custom_btn" type="submit" onclick="goBack()" value="SUBMIT" />
<SCRIPT LANGUAGE="JavaScript">
function goBack() {
    window.history.go();
}
document.getElementById("caspioform").onsubmit = goBack;
</script>
</div>

 

 Try calling a function onload:

<SCRIPT LANGUAGE="JavaScript">
window.onload=function goBack() {
    window.history.go(-1);
}

</script>

Hope that helps ;)

Link to comment
Share on other sites

  • 0

Hi Mathilda,

That works fantastic- many thanks for the simple, elegant solution. I just had to change go(-1) to go(-2) because the submit page refreshes upon submission so to get back to the page before it originally loaded requires a -2.  But that's excellent-thanks again!

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
Answer this question...

×   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...
×
×
  • Create New...