• Resolved oventawebdesign

    (@oventawebdesign)


    Hello, I have a question.

    A client of mine has a car rental website, we have unique pages per car type and car name. For example when I go to this page: https://allcar.nl/personenbusjes/mercedes-vito-9-persoonsbus-huren/ and I click the ‘reserveren’ button on that page, it’ll redirect to the form, but I want it to automatically fill out that this type of vehicle is a ‘9-persoonsbus’. And if we have more options for cars i want it to select the vehicle type + the exact car from the previous page.

    How can I do this, I have no clue and I saw some javascript code but can’t seem to get that to work.

    Thank you.

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

Viewing 1 replies (of 1 total)
  • Plugin Support Zhanna Khachatryan

    (@zhannak)

    Hello @oventawebdesign,

    Thanks for your inquiry and sorry for the late response.

    First, the “reserveren” button link should be changed to /reserveren/?type=9-persoonsbus.

    Then in the form’s js section should be added this code in the before_load() function:

    var queryString = window.location.search;
    var urlParams = new URLSearchParams(queryString);
    var type = urlParams.get('type'); //type is a parameter in the url.
    jQuery('#wdform_20_element1 option[value="' + type + '"]').attr('selected', 'selected'); // wdform_20_element1 is a type field id.

    Please also note, that the type field options’ names should be the same with passed parameter in the URL, so the select option value should be “9-persoonsbus”. Please see the screenshot https://nimb.ws/kn128J.

Viewing 1 replies (of 1 total)

The topic ‘Get value from page id select type’ is closed to new replies.