What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    JotForm Widget API not returning Value on onReady event

    Asked by theculturetrip on December 01, 2014 at 03:35 PM

    Hi

    Your API documentation says that subscribing to the Ready event will call the callback function with formID and value as arguments. 

    I have logged the output of this function and am seeing an object with more fields, but no value, it is always null. I'm trying to retrieve the value of the field and display it when the form is edited from the submissions list, and so the user can return to the form and complete.

    This is the code that I'm using in my widget:

    JFCustomWidget.subscribe("ready", function(form){

                console.log(form);

                //subscribe to form submit event

                if(form.value){

                    console.log('form value:'+form.value);

                    $('#countries').val(form.value);

                }

    ........

     

    Console.log(form) displays the output that I've attached. As you can see the value is null, even though I have previously submitted this form with a value.

    Could you let me know if this is a problem with my code (if so I can't spot it!) or if it is a bug with the API and when it might be fixed? I have a project that is using your system, but this is quite fundamental to that form behaving as it should.

    Many thanks

    Jordan

    Page URL:
    http://www.jotform.com/submissions/43294862453360

    Screenshot
    JotForm widget api
  • Profile Image
    JotForm Support

    Answered by Mike_T on December 01, 2014 at 04:52 PM

    Thank you for contacting us.

    You request has been forwarded to our Development Team.

    We will keep you updated via this thread.

  • Profile Image
    JotForm Support

    Answered by widgets on December 02, 2014 at 01:50 AM

    Hi @theculturetrip. If its okay can you attached a sample submission ID of that form you gave. So that I can check it before giving you some advice.

    Looking forward! thank you!

  • Profile Image
    JotForm Support

    Answered by widgets on December 02, 2014 at 02:00 AM

    Okay nevermind, I was able to check it directly by checking your form. And I can confirm that the ready event still pass the value of the widget from the previous submission. Also what was the submission ID when you try to edit the submission? Look at this image.


    Always make sure that you must use this function to send the value of the widget
    :First listen to submit event of the form and then submit the value
    JFCustomWidget.subscribe("submit", function(){
        JFCustomWidget.sendSubmit({
            valid: (isValid) ? true : false,
            value: 'the widget value'
        });
    });

    Does your widget have this piece of code that is sending the widget value to the form?

  • Profile Image

    Answered by theculturetrip on December 02, 2014 at 02:19 PM

    Hi.

    Thanks for coming back to me. Yes, the widget has a sendSubmit, and also a sendData when it changes. Strangely in Chrome (v34) I'm not seeing the value when I edit a submission, as you do. However, testing in Firefox I do get the value in the form object.

    Here's one of the sample submission IDs from that form: 293275554700820054 

    Am I correct in assuming that if I use sendData to send values back as they update, then a reload of the page should reload the widget passing that value back in? 

    I've reverted to using localStorage in my widget to store the saved data, which seems to be working, but would be good to understand what the designed behaviour is here, and if you can replicate my issue in Chrome.

    Thanks 

  • Profile Image
    JotForm Support

    Answered by widgets on December 03, 2014 at 01:11 AM

    Hi, thank you for that information. It really is strange why it not works in chrome browsers, as I'm not really able to replicate it myself. Did you try to clear the browser cache when you checked the previous edited value?

    Also can you try to visit this page. This is a sample edit form submission page which you can generate by putting {edit_link} to your thank you page or email notification. But for now please click the link and let me know if you get the right value you are looking for. Use the chrome browser as much as possible.

    On your other question:
    once you reload the page you will not get the value unless it has been submitted. sendData is only a helper to update the form real time. This is to avoid missing data once submitted.

    Thanks