Is there a way I can make a dropdown box that will allow me to load the values from a file and/or an ajax response?

  • Profile Image
    aaronedmistone
    Asked on July 28, 2017 at 02:28 AM

    Hi all, this answers my questions, apologies, I know this is an old thread, but the information is still relevant.

     

    The server.php file that fills the data is not accessible from outside of jotforms, even when pointing to the particular php file and sending the same request data, it doesn't pass the access control check and is blocked due to this. Understandable.

     

    My issue is that my Jotform needs API calls to fill data at runtime from our project management software.

     

    In short, is there a way I can do either of the following?

    Make a dropdown box that will allow me to load the values from a file and/or an ajax response (data needs a little extra code after the response to sort it)?

    or

    Run my form as I am currently doing externally (allowing me to keep the custom code), and also populate the data and keep the SID externally when I want to edit the submission?

     

    If not am I correct in that I would have no other way then handling the data saving, populating, editing and notification process with my own code? If so ouch. but I will do it.

  • Profile Image
    Nik_C
    Answered on July 28, 2017 at 02:36 AM

    I'm pretty sure that the only way you would be able to do that is to download the source code of your form and populate the dropdown from an external source by coding there.

    So that would be the second option I would say.

    Since there is no way to pull the data from outside of the form and populate the drop-down field.

    If you have any further questions please let us know.

    Thank you!

  • Profile Image
    aaronedmistone
    Answered on July 28, 2017 at 03:21 AM

    Wow, fast response, thank you and yes I am currently implementing the 2nd method but need help.

     

    I have the source code for the form, runs nicely in an external html file.

    I even have the dropdown box being populated with the ajax response, that works fine too.

     

    The only issue that I am having now is that when I try to edit the form, after making a submission, with the edit link, it is linking to the form hosted with jotform.com instead of editing the form hosted on my server.

    Due to this I am losing the population of the dropdown box as the source code of the form hosted at jitform.com is not the same as the source code hosted on my server.

     

     

    So to be clear, I am asking; Is there a built-in way to edit an externally hosted form?

    (e.g. http://www.mywebsite.com/myform.html?mode=edit&sid=123456789123)

    I need it to pull the data saved in the submission for that SID and fill my externally hosted form.

     

    If this is a feature available in a higher plan etc. I am happy to go with that.

     

    Thanks for your time, cheers.

  • Profile Image
    ashwin_d
    Answered on July 28, 2017 at 03:36 AM

    Hello aaronedmistone,

    Unfortunately no. Please note that if you edit your submission data, it will always redirect you to JotForm site to edit submission. It is not possible to edit submissions with form hosted in external server. 

    The best possible way is to use JotForm API to fetch specific submission data and populate the form hosted in external server. Please review our API guide to fetch submission ID:  http://api.jotform.com/docs/#submission-id

    Thank you!

  • Profile Image
    aaronedmistone
    Answered on July 28, 2017 at 03:45 AM

    Your support team is awesome guys, your response time is unbelievable.

     

    Providing the API is able to retrieve the submission data, I can use that to populate my external form, and I imagine I could use the API to make updates to the submissions.

    Very simple, elegant solution, thanks.

  • Profile Image
    Nik_C
    Answered on July 28, 2017 at 03:54 AM

    You're very welcome. 

    We're glad we could help. 

    If you encounter any API-related issues you can contact our API support at api@jotform.com since they will be able to provide you more assistance.

    Cheers.

  • Profile Image
    aaronedmistone
    Answered on July 30, 2017 at 04:28 AM

    Hi guys,

     

    Tldr; How to have dynamic data in input fields and edit submission data externally

    Just wanted to leave anyone stumbling across my question with a final outcome.

    The advice to look into the API was spot on.

     

    To be clear, I wanted to have a drop down box automatically filled with custom data that changes every few hours during work days and would take me ~30mins each time it changed to manually add the info to the drop down box.

     

    I ended up adding a javascript AJAX call to the header of "www.mywebsite.com/travel-form" that would make and API call (POST form change) to alter the options in the drop down box.

     

    Specifically I made it:

    Get the data I needed in a response and sort the data

    Make the AJAX API call to change the options in the dropdown box

    Wait for the response, then load the form in an iframe

    Works perfectly.

     

    Bonus is that I was able to capture any url variables (?sid=123 etc.) using my header javascript and if I detect an sid I can parse that and load a different iframe to edit the submission externally.

    Works beautifully.

     

     

     

  • Profile Image
    Nik_C
    Answered on July 30, 2017 at 04:56 AM

    Thank you for sharing your solution, we appreciate that and I'm sure it will help our fellow users.

    I'm glad you were able to make it work.

    Do not hesitate to contact us if you need anything else.

    Thank you!