Prepopulate URL to a form field

  • pvhwoo
    Asked on February 27, 2022 at 1:06 AM

    Hi,

    For point 3, it is just a URL from google Map API and want to load it into one of your text box input

    https://maps.googleapis.com/maps/api/distancematrix/json?destination=address2&origin=address1

    Would it be possible?

    Thanks!

  • Rahul JotForm Support
    Replied on February 27, 2022 at 1:08 AM

    Hi Philip,

    Thanks for your reply,

    Yes, you can use prepopulate functionality to pass this URL into a form field.

    Related Guide: (You may refer to our guides below to know more about prepopulate functionality)

    What Is Jotform Prefill and How Does It Work?

    Prepopulating Fields to Your Jotform via URL Parameters

    How to Prepopulate the Same Form with Data from a Previous Submission?

    Direct responders to prefilled forms through your Thank You page


    Regards,

    Rahul Aggarwal

    Jotform Support Team

  • pvhwoo
    Replied on February 27, 2022 at 7:26 PM

    Hi Rahul,

    Thank you for the reply.

    In response to your answers above, how do we include the json data result of the following URL:

    https://maps.googleapis.com/maps/api/distancematrix/json?destination=address2&origin=address1

    to one of the jotform input box?

    Will this format work:?

    https://jotform.com/xxxxxx?inputbox1=product&inputbox2=https://maps.googleapis.com/maps/api/distancematrix/json?destination=address2&origin=address1

    Would the json result from the googleapis.com be prepopulated into inbox2?

    Or is there a special html syntax format we need to use?

    Thank you and Kind Rgds,

    Philip

  • Rahul JotForm Support
    Replied on February 27, 2022 at 10:33 PM

    Hi Philip,

    Thanks for getting back to us.

    Can you please share the Form IDs/Links you are trying to implement this functionality so that we can check and assist you further accordingly?

    We look forward to hearing from you.


    Regards,

    Rahul Aggarwal

    Jotform Support Team

  • pvhwoo
    Replied on February 28, 2022 at 2:07 AM

    Hi Rahul,

    Form is: https://www.jotform.com/build/220550910059449

    Please refer to the first 3 input boxes and ignore the remainder of input boxes.

    Origin (prepopulated in input box 1) ) and Destination address in input box 2 which user will enter.

    (Note: origin address changes every time the form is called and not static.. it needs to be prepopulated and hence the current jotform distance widget does not work as it cannot prepopulate the origin adddress)

    The 2 above addresses are to be passed to the following URL as :

    https://maps.googleapis.com/maps/api/distancematrix/json?origin=inputbox1&destination=inputbox2....

    assuming inputbox1 and inputbox2 are the origin and destination addresses respectively

    Such URL outputs a json formatted distance (km) and such result is to go into the 3rd input box

    We then intend to use the above to further calculate the chargeable fees based on a price formula.

    If the above is not possible, any other alternatives?

    Thanks.

  • pvhwoo
    Replied on February 28, 2022 at 2:12 AM

    Ideally, it would be great if the inputbox 1 in the distance widget can be made prefillable and that removes the need to use the google map api url. Any chance of making it as such. I have seen that some other users have been inquiring the same flexibility. Thanks.

  • Israel JotForm Support
    Replied on February 28, 2022 at 2:29 AM

    Hi there,

    Thank you for reaching out to us at Jotform Support.

    Please allow us some time to review the available information and will get back to you as soon as possible.

    Thanks for your patience and understanding.

    Kind regards,

    Israel


  • Israel JotForm Support
    Replied on February 28, 2022 at 3:25 AM

    Hi again,

    I have been testing and was unable to find a widget that will met your requirement, none of the widgets will show a link to the Google Maps location, the default address field will display a map on the submissions page if the entered address is valid. 

    However, I think you may achieve it with a workaround, for example, you may use the Geolocation widget to get the lat and long only and then you could generate the query to show where the location is on the map. 

    Here are the steps: 

    1. Add the Geolocation widget to your form and configure it to have the long and lat only. 

    Prepopulate URL to a form field Image 10

    2. Add a text element to the form and add the link like this: https://www.google.com/maps/search/?api=1&query={YourFieldName}

    Replace the "YourFieldName" with the name of the Geolocation widget, this guide will help you getting it: https://www.jotform.com/help/146-How-to-Find-Field-IDs-and-Names 

    Prepopulate URL to a form field Image 21

    Prepopulate URL to a form field Image 32

    You will notice that the link changes as you change the location, unfortunately, I could not get it have an hyperlink so your users will need to select the link and open in a new tab. 

    Also, instead of displaying the link on the form you could include it in an email, the process will be basically the same you just will not add the text element. 

    Here's my sample form: https://form.jotform.com/73167426735967 

    I hope this helps. 

    Kind regards,

    Israel

  • pvhwoo
    Replied on February 28, 2022 at 4:03 AM

    Hi Israel,

    Thank you for the reply + for trying to help. Much appreciated.

    But I am not sure if I follow your workaround solution but I am lost as to what users need to do.

    What happened when user click on the url link?

    The objective here is to get the distance between 2 locations with a prefilled address from an form url being a key requirements. Having users to do lots of activities would be counter productive.

    Ideally, it would be great if the inputbox 1 in the distance widget can be made prefillable and that removes the need to use the google map api url. Any chance of making it as such. I have seen that some other users have been inquiring the same flexibility. Thanks.


  • Maruel_T
    Replied on February 28, 2022 at 4:24 AM

    Hi there,

    What my colleague meant is that it don't have any hyperlink to redirect it from the form so your user's can copy the link directly and open it in a new tab.

    Actually, we don't have a widget that you require as the distance widget in the form is only between km and miles.

    Let us know if you have any further inquiries.

    Thanks.