• Resolved zukenstein

    (@zukenstein)


    Hi I am trying to link out to open a new page when someone selects a checkbox. I have tried the following but it doesnt seem to work

    I am trying to open a separate window at https://81b.co.uk

    I have inserted a calculated field in the form linked to show from a checkbox being selected and added the function

    (function(){
    document.location.href="https://www.81b.co.uk" target="blank";
    })()

    Finally in the the “Form Settings” tab I’ve unticked the checkbox: “Eval dynamically the equations associated to the calculated fields”,

    But not doing anything when the tickbox is ticked.

    Thanks for any help

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    No, your code is incorrect.

    First, the document.location.href redirects the current page to the new URL, it does not open a new page. Second, the target attribute is used into a link tag, and not not the equation in the way you did. Third, if the equations are evaluated dynamically, and you want the new window be opened after the user select an option in the checkbox field, you should to use conditional statements into the equation.

    For example, assuming the name of the checkbox field is the fieldname1, and you want to open the new window when the option be ticked (the field’s name is hypothetical, only to describe the process, you should to use the name of the corresponding field in your form), the equation would be:

    
    (function(){
        if(fieldname1)
            window.open("https://www.81b.co.uk", "_blank");
    })()
    

    and that’s all.
    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Worked like a charm, excellent thank you! ??

    Thread Starter zukenstein

    (@zukenstein)

    Sorry something I have just noticed i saw when it opened the new window a pop up was blocked as well. With the pop up blocker switched off it opens the page twice???

    Why would it open it twice? I tried giving the fieldname a specific value as well just in case it was needed, but it still did it.

    (function(){
        if(fieldname136 == 'a1price' )
            window.open("https://www.81b.co.uk", "_blank");
    })()

    Thanks

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    Note the equations are evaluated dynamically, if you want the page be loaded only once or at least into a same tab, you should edit the equation as follows:

    
    (function(){
        if(fieldname136)
            window.open("https://www.81b.co.uk", "MyNewWindow");
    })()
    

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    That’s great that sorted it thanks very much

    Thread Starter zukenstein

    (@zukenstein)

    Hi again Problem I’ve found with the solution you kindly provided. When I select the checkbox it opens the new window once which is great. If I close that window, return to my form and click on any OTHER field, it opens the external window again. The checkbox is still checked at this time from where it was selected originally.

    Is there a way to stop that from happening? I still want the check box to be ticked as it opens other fields as well.

    Many thanks I do love this plugin!

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    Please, send me the link to the page with the form. Furthermore, indicate the fields’ values to emulate the issue from my side.

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Hi thanks for the speedy reply

    I have set up a page to demonstrate here:

    https://81b.co.uk/cff-test

    Checkbox is fieldname136 and has value ‘a1price’ when selected

    Hidden calculation field is fieldname481 and has this function

    (function(){
        if(fieldname136 == 'a1price' )
            window.open("https://www.81b.co.uk/sold_prices_search", "MyNewWindow");
    })()

    If you check checkbox and open new window then close the new window and click on input ‘Price per SqM’ it will open the external window again.

    I need for the checkbox to stay checked as it opens other fields as well.

    Thanks very much

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    Please, edit the equation associated to the calculated field as follows:

    
    (function(){
        if(fieldname136 == 'a1price' && (typeof fieldbk == 'undefined' || fieldbk != fieldname136))    
            window.open("https://www.81b.co.uk/sold_prices_search", "MyNewWindow");
        fieldbk = fieldname136;
    })()
    

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Ok Tried that and it still opens the external window for a second time.

    If you close the ext window for the second time and click on ‘Price per SqM’ again it doesn’t open it for a third time.

    Thanks sorry to be a pain.

    Plugin Author codepeople

    (@codepeople)

    Hello @zukenstein

    Please, tick the checkbox: “Merge ticked up options (sum or concatenation) or their values are returned as an array.” in the settings of the checkbox field

    – Or –

    Edit the equation as follows:

    
    (function(){
        if(fieldname136 == 'a1price' && (typeof fieldbk == 'undefined' || fieldbk.toString() != fieldname136.toString()))    
            window.open("https://www.81b.co.uk/sold_prices_search", "MyNewWindow");
        fieldbk = fieldname136;
    })()
    

    Best regards.

    Thread Starter zukenstein

    (@zukenstein)

    Hi
    Ticking the ‘Merge ticked options’ did nothing, but editing the equation worked great!

    Once I get this all set up I will be buying the paid version so your efforts will reward you!

    Thanks very much.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Link out to external url from checkbox’ is closed to new replies.