Forums Forums Search & Filter Pro Pass the search value between forms/results

  • This topic has 20 replies, 2 voices, and was last updated 4 years ago by Anonymous.
Viewing 10 posts - 11 through 20 (of 21 total)
  • Anonymous
    #266411

    Hi

    before digging into this let me ask a question

    should I have

    Basic form
    Advanced 1
    Advanced 2

    Or
    Basic 1
    Basic 2
    Advnaced

    — I assumed one basic and two advances
    so I enter the data in the basic and advanced 1, and on submit of advanced 1 it goes to custom wich is actually advanced 2

    right

    Trevor
    #266413

    Option two should be fine, as long as it has the same fields and field types as the ‘basic’ form (so, a copy), as it is on the same page.

    Anonymous
    #266422

    Ok it’s all up

    basic 1 and 2 have one texte seaech field and a submit button,
    1 is ajax
    2 is custom and Url is advanced

    if i enter a value in basic 1, the results are loaded in ajax in the result shortcode on basic

    if I type in the same value in basic 2, I’m redirected to advance search page, with the value in the url, and the field of advanced is indeed populated

    I guess we could create a php script to programamtically copy basic1 value in basic 2, and then use basic 2 button to go to advanced….
    and we need to hide all basic 2 field expet submit button

    is that your plan ?

    Trevor
    #266556

    That is indeed what I was going to suggest you do next. In fact, form #2 could have Auto Submit OFF, and not submit button, and you simply place an Advanced button on the page, with javascript to copy the values over to the hidden fields, and then submit that form, using something like (assuming form #2 has an ID of 1234):

    $('.searchandfilter[data-sf-form-id="1234"]').submit();

    Anonymous
    #266567

    Hi,

    yes this could work !

    Could you provide me with a starter sniplet to programatically “copy” each field content from basic 1 to basic 2 ?

    The ideal solution would be for this sniplet to copy the two field if there are two, three is there are three, and so on, so the only variable to change in the sniplet would idealy be the IDs of the origin and destination form.

    As such it could be used more than once, to copy formA1 into formA2 and formB1 in formB2.
    the idea is to have several basic search form, context based, and a single advanced search form (or site wide search).
    There is a good starting point here but as there are many field type (text, radio, checkbox, etc.), and I have no clues of the structure and storage of the value of each type, I’ll crowl endlessly.

    Thank’s

    Trevor
    #266571

    That is not something I could do. You may need to seek some third party help with that, but here are some snippets using the JavaScript val() function in our forum:

    https://support.searchandfilter.com/forums/search/.val/

    Anonymous
    #266601

    Yes,

    I understand that this is not a native feature of S&F and may be slightly beyond the scope of the basic support, but the possibility to have two seach form on the same page is exactly the reason why I went for S&F vs. Facetwp.

    I do have two use case in mind.
    One is purely as we addressed above.
    Have a search fomA on one page,
    search formB on the other,
    and send the value to sear formZ on a third page. Search formZ value could be pre-populated when getting to its page form from formA or formB.

    The other use case is why havig two form on the sme page is critical.
    I want to place a S&F form in a mega menu container. This would provide a basic search tool on selected post types, and results, but the user may broaden or refine his search, that’s when he could click on a button and reach the advanced search page, with the form pre-populated (let’s be ux friendly).
    The fact is this mega menu is on every page, while some pages have search form themselves, these are scopped search. these form will only look in certain categories or post type.
    that’s where facetwp won’t work, as one could only have one search per page.

    All togather, I also wonder if it wouldn’t be an easier road to use the values in the url when a search is done.
    one do a search, the url change for instance : /?_sf_s=demo&_sft_custom-tax=boo
    the js, just get this in the url that changed using ajax, and add it at then end of its own link ?

    There would be no fuss with two forms, no need for js to get and duplicate values programatically, as thy are already there ?

    No ?

    Trevor
    #266739

    That could also work. It is up to you how you want to do this. But, values in the URL would work. Multiple forms on the results page will not work though.

    The next version of our plugin, V3, due in a few months, allows you to split the form up across a page (different fields in different places), have duplicate fields and much more.

    Anonymous
    #266907

    Hello

    yes I’ve implemented it this way, it’s still on work but it basically works.

    To my experience, multiples forms still work as long as only one form, the one sending the date to the others display value in url.

    V3 sounds nice, spliting the form could be cool, as well as some conditional logic to display field (based on url, field value, etc.)

    regards

    Trevor
    #266923

    Is it OK to close this thread for now?

Viewing 10 posts - 11 through 20 (of 21 total)