• Resolved mastanx

    (@mastanx)


    Hello everyone ??

    My goal is to generate and be redirected to an url from an input field.

    In detail: I have field1 (that is a number or text field) and a button. If I write in that field for example “zero”, I want that if I click the button, I will be redirected to “website.com/zero”. So in the background there has been generated “website.com/ + zero”.

    Is it possible to do that with Calculated fields form?

    I already tried something with the h.ref and the generateURL functions, but it didn’t worked. I’m not that good at coding so maybe someone can help me.

    Greetings from Switzerland ??

    • This topic was modified 4 years, 6 months ago by mastanx.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @mastanx

    The simplest solution:

    1. Untick the checkbox: “Eval dynamically the equations associated with the calculated fields” in the “Form Settings” tab.

    2. Select the “Calculate” option as the button’s type.

    3. Insert a calculated field (you can configure as hidden by ticking a checkbox in its settings) with the following equation:

    
    redirectToURL('https://website.com/'+fieldname1)
    

    In the previous code, I’m assuming the fieldname1 field is who contains the zero value. You must use the name of the field in your form.

    Best regards.

    Thread Starter mastanx

    (@mastanx)

    Hello @codepeople

    Thank you very much for your fast response. That worked perfectly!

    Grettings

    • This reply was modified 4 years, 6 months ago by mastanx.

    Hello @codepeople ,

    I have used the suggestion above to redirect to a website depending on the result of a calculated field.
    It works the first time I use the form. After the second time it redirects to the webpage immediately when starting the form, even without filling out anything.

    Do I have to reset the form somehow?
    Thanks a lot
    Best regards

    Plugin Author codepeople

    (@codepeople)

    Hello @wilmawerkl

    Please, go to the “Form Settings” tab (https://cff.dwbooster.com/images/documentation/form-settings-tab.png) and be sure this section is configured as follows:

    1. Disable the dynamic evaluation of the equations.
    2. Disable the autocomplete option.
    3. Disable the browser’s persistence.

    Best regards.

    Hi @codepeople

    Thanks for the quick response. It was the browser’s persitence button.

    Now I have some more (stupid) questions:

    Is it possible to calculate and show the results of the first part of the form and then calcute the next part and redirect to a webpage?

    Is it possible to redirect to a webpage only if a certain condition is met?
    With this example:
    IF(fieldname1==1,redirectToURL(‘www.website.com’),”stay here”)
    I will allways be redirected to the website once I hit the calculate button, no matter the vaule of fieldname1.

    Thanks a lot in advance
    Best regards

    Plugin Author codepeople

    (@codepeople)

    Hello @wilmawerkl

    The calculate button evaluates all the equations are in the form and not some of them. However, you can include conditional statements in the equation to redirect the user only if the condition is satisfied.

    For example, assuming you have the fieldname1 field with two possible values: Yes and No, and you want to redirect the user only if the “Yes” option was ticked. The equation associated with the calculated field would be similar to:

    
    (function(){
    if(fieldname1 == 'Yes') redirectToURL('https://website.com/');
    })()
    

    Best regards.

    Hello everyone,

    My goal is similar to @mastanx. I want to generate and be redirected to an url from two imput fields, one is a Text Field like “zero” and the other one is a Date Format Field “2021-04-07″(yyyy-mm-dd).

    I tried to follow the suggestions of @codepeople but i didn’t manage to obtain the expected result.
    I have inserted in the Custom Field

    redirectToURL('https://website.com/'+fieldname1+'/'+fieldname2)

    Instead of obtaining: https://website.com/blog/2021-04-07
    I got this instead: https://website.com/blog/18724

    Is it possible to do that with the date format field?
    Sorry,I’m not good at coding… I hope someone can help me.

    Best regards.

    Plugin Author codepeople

    (@codepeople)

    Hello @ngreign

    You should use the CDATE operation to format the date value as text:

    
    redirectToURL('https://website.com/'+CDATE(fieldname1, 'yyyy-mm-dd')+'/'+fieldname2)
    

    Best regards.

    Hello @codepeople

    Thanks for the fast response, that worked perfectly.

    Best regards.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Generate URL from input field’ is closed to new replies.