• Resolved xbhy

    (@xbhy)


    Hello,
    thank you very much for this great plugin!

    I’m trying to do something similar to what is discussed here:
    https://www.ads-software.com/support/topic/generate-url-from-input-field/

    I want to create a library search form that works like this one:
    https://triocasci.cz/knihovna/

    It generates a URL (with results on another web) from the input fields such as:
    https://svobodnaknihovna.cz/cgi-bin/koha/opac-search.pl?idx=ti&q=test&limit=branch%3Aka3o&weight_search=1

    I have a CFF form with the following settings:
    Display loading form animation – disabled
    Enable autocompletion – disabled
    Enable the browser’s persistence – disabled
    Dynamically evaluate the equations associated with the calculated fields – disabled
    Eval the equations in the onchange and keyup events – enabled

    And with the following fields:

    fieldname1 – Single Line Text
    fieldname2 – Dropdown – Choices – Text Autor, Value =au etc. for other choices
    fieldname3 – Dropdown – Choices – Text BibLib, Value =branch%3ABIBLIB etc.
    (both fieldname2 and fieldname3 have Value to submit: Choice Value)

    fieldname4 – Calculated Field:
    Read Only and Hide Field From Public Page are enabled
    Set equation:
    redirectToURL('https://svobodnaknihovna.cz/cgi-bin/koha/opac-search.pl?idx'+fieldname2+'&q='+fieldname1+'&limit'+fieldname3+'&weight_search=1')

    fieldname5 – Button – type calculate:
    OnClick event:
    jQuery(this.form).submit();

    The form looks fine visually, but when I click the button, instead of redirecting to the desired URL, I am redirected to https://plac.triocasci.cz/zakladna/knihovna/?

    What am I doing wrong? Is there a problem with the special characters in the values or is my OnClick event bad?

    Thank you very much
    Petr

    • This topic was modified 2 years, 8 months ago by xbhy. Reason: changed the URLs to code

    The page I need help with: [log in to see the link]

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

    (@codepeople)

    Hello @xbhy

    If your equation includes a redirection, you should not submit the form.
    Implement the equation as follows:

    redirectToURL('https://svobodnaknihovna.cz/cgi-bin/koha/opac-search.pl', {'idx': fieldname2, 'q': fieldname1, 'limit': fieldname3, 'weight_search': 1});

    And then, you should insert a button in the field, with the calculate option selected as its type, and do not enter any onclick event.

    Best regards.

    Thread Starter xbhy

    (@xbhy)

    Wow, thank you very much for the very fast reply, it works perfectly now!

    Thread Starter xbhy

    (@xbhy)

    Another thing – what if I want to open the generated URL in a new tab?

    Here https://www.ads-software.com/support/topic/how-to-make-a-button-in-cff-work/
    It is suggested to use window.open() but I suppose it is more complicated than just replacing redirectToURL with window.open and adding , “_blank” – is it?

    Thank you.

    • This reply was modified 2 years, 8 months ago by xbhy. Reason: added , "_blank"
    Plugin Author codepeople

    (@codepeople)

    Hello @xbhy

    You can implement the equation as follows:

    window.open(generateURL('https://svobodnaknihovna.cz/cgi-bin/koha/opac-search.pl', {'idx': fieldname2, 'q': fieldname1, 'limit': fieldname3, 'weight_search': 1}), '_blank');

    Best regards.

    Thread Starter xbhy

    (@xbhy)

    Thank you, it works great. However, I had to replace your abstraction with key/value pairs with my original string-based approach. Because with the key/value pairs, the library selection didn’t work for some reason, the result was for all the libraries every time.

    Now I have it like this:

    window.open(generateURL('https://svobodnaknihovna.cz/cgi-bin/koha/opac-search.pl?idx'+fieldname2+'&q='+fieldname1+'&limit'+fieldname3+'&weight_search=1'), '_blank');

    and it works perfectly.

    Plugin Author codepeople

    (@codepeople)

    Hello @xbhy

    In this case, you don’t need the generateURL operation. The equation can be implemented as follows:

    window.open('https://svobodnaknihovna.cz/cgi-bin/koha/opac-search.pl?idx'+fieldname2+'&q='+fieldname1+'&limit'+fieldname3+'&weight_search=1', '_blank');

    Best regards.

    Thread Starter xbhy

    (@xbhy)

    Thank you, it works great.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘redirectToURL doesn’t seem to work’ is closed to new replies.