Skip to main content
Question

How can I save and redirect to a home page

  • February 19, 2014
  • 0 replies
  • 448 views

I'd like to save data input into a form and then return users to a specific page after clicking "save" on a custom button. My button works great - just don't know how or where to add the code to then redirect url to the home page.

This topic has been closed for replies.

Forum|alt.badge.img+14
  • Registered
  • February 19, 2014

Forum|alt.badge.img+7
  • Registered
  • July 13, 2015
Try this

onclick='var url = [insert your homepage url here]; document.getElementById(\"RedirectURL\").value = url; DoSave();

Forum|alt.badge.img+14
  • Registered
  • July 14, 2015
Did you test this?

Forum|alt.badge.img+7
  • Registered
  • July 14, 2015
It's similar to a button I've set up with the code below (which works), so should work:

<div class='button' onclick='var url = \"[url for a page]\"; document.getElementById(\"RedirectURL\").value = url; DoSave();'>Save</div>

  • Registered
  • July 14, 2015
I don't think the above code will work. The hidden field RedirectURL is only used to control the redirection process when the hidden field rl is empty (and if you are coming from a report listing page it will not be). So you also have to set the rl field to an empty string to make the redirection process work. Complicating this somewhat is the fact that the RedirectRUL <input> has and id attribute while the rl <input> has only a name attribute. All these oddities combine to make forcing JavaScript into the formula language a small nightmare to edit without creating a typo.

You are better off using the UNOB technique to make your QuickBase formula dead simple and throw all the logic and processing into module.js using the image onload technique.

UNOB Technique
https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=dr&rid=371

If you have not familiar with this approach you may think I am complicating the problem - nothing could be further from the truth. Once you set up the image onload technique all you future customizations become easy to implement. You will be amazed at what these techniques can do for you - all  problems solved in a few lines of script.

  • Registered
  • July 20, 2015
I still think you should use the UNOB technique but if you are dead set on using an onclick attribute here is a nice trick to get the redirect to work in all circumstances.

It is a little know fact but all modern browser automatically create global variables for every element with an id attribute. This means that there is already a global variables for RedirectURL and you don't even have to call getElementByID("RedirectURL"). You can just set its value with this simple statement:

RedirectURL.value=[insert your homepage url here];

Browsers do not automatically create a global variable for all elements with a name attributes - but they do for named forms (and a few others). So you can access the hidden rl name attribute as follows and set it to an empty string:

editform.rl.value="";

These are the two conditions you need to setup to gain full control of the redirection process QuicBase uses. So if you are dead set on using an onclick handler this should work under all conditions:

<div class='Vibrant Success' onclick='RedirectURL.value=[insert your homepage url here];editform.rl.value="";DoSave();'>Save</div>