Dear Softr Community,
I am writing to seek guidance on how to create a JavaScript code in the header section to update the src of my iframe, with calculated fields from tally’s form, bypassing the redirected to a new page.
To provide some context, my app displays different Tally’s forms into an iframe loaded from an Airtable field into the inbox block. I am using Tally’s conditional logic, which is easy to implement with their GUI, to update the src of the iframe. However, I am facing issues with loading the inbox block with a custom script in JavaScript.
In my use case, I need to display different Tally’s forms in an iframe loaded from an Airtable field into the inbox block. Tally’s form allows for redirecting to a custom URL when the form is submitted. However, when I tried to implement the form in Softr, it redirects to a new page instead of updating the src of the iframe. To add to the complexity, I am also using Tally’s calculated fields to update the values of some fields based on the user’s inputs. As mentioned earlier, my use case requires me to only update the src of the iframe and not redirect to a new page.
I have tried different methods, but I am still struggling to implement the code suggested by the Tally community:
const data = JSON.parse(e.data);
data.payload.fields
window.addEventListener('message', (e) => {
if (e && e.data && e.data.includes('Tally.FormSubmitted')) {
// e.data also contains the form data
// redirect here
}
});
My script aims to streamline the process of displaying Tally’s forms into an iframe and updating the src of the iframe based on Tally’s conditional logic and the generated hidden calculated fields. I know calculated field will be available in the form data via e.data
and fields is an array with all form data.
I would greatly appreciate it if someone from the Softr community could provide me with some guidance on how to implement this code or suggest an alternative solution.
Thank you in advance for your help.
Lea