Form embed option as submission counter link?

  • Profile Image
    nhamwey
    Asked on December 12, 2017 at 10:24 AM

    Is there any way to have a submission counter be a link to one of the embed options?

    The popup and lightbox embed work well, but I just want to have a submission counter as the link to make them pop up.

    I know how to code, so I can change the link, but I was wondering if there is any way to make the functionality of the form work outside it on my website.

    Thank you

  • Profile Image
    EltonCris
    Answered on December 12, 2017 at 11:20 AM

    We have a submissions counter widget which you can only add in your form but you can't put a hyperlink in it.

    However, if you know programmings like PHP or Javascript, you can simply get your form's total submission through API http://api.jotform.com/docs/#form-id then hyperlink it with a lightbox embed or a popup embed.

    Let us know should you require further assistance.

    Regards

  • Profile Image
    nhamwey
    Answered on December 12, 2017 at 12:09 PM

    Do you have an example on how to format this? It doesn't seem to work like other APIs I have used.

    I have this code for my API and form:

    curl -X GET "https://api.jotform.com/form/{73422511684151}?apiKey={d9b0f3e377ac5108046699b43efebbd1}"


    How do I format this? (<script src="?)

    This will get the info I need, but then I need to use java to retrieve the count and display it where I want on my site correct?


  • Profile Image
    aubreybourke
    Answered on December 12, 2017 at 01:01 PM

    1. Language

    curl is only available to Linux users. 

    You should use JavaScript (or any of the supported languages you like).

    To switch the language click on the dropdown list on the top left hand side.

    15131000453.png


    2. API example

    To get the form submission data you need to go here:

    http://api.jotform.com/docs/#form-id

    If you run the example you will see the count listed in the response.


    3. How to get the count

    So first you would need initialize with your API key:

    JF.initialize({apiKey: "d9b0f3e377ac5108046699b43efebbd1"});


    Then pass the formID 73422511684151 to this function:

    JF.getForm(formID, function(response){

    /** successful response including form data with given id . */

    document.write(response.count); });


  • Profile Image
    aubreybourke
    Answered on December 12, 2017 at 03:40 PM

     Just trying to get a working demo for you. But I have other threads to answer as well. So I will try some more testing and get back to you later on.

  • Profile Image
    nhamwey
    Answered on December 12, 2017 at 04:09 PM

    No problem, I should be able to figure this out now that I am on the right language

  • Profile Image
    aubreybourke
    Answered on December 13, 2017 at 09:45 AM

    Got it!

    You will need to name this file as "index.html" and place it in a web server for it to work:


    <!DOCTYPE html>

    <html>

    <title>Count</title>

    <head>

    </head>

    <body>

    <div id="counter">

    </div>

    <script src="https://js.jotform.com/JotForm.js"></script>

    <script>

    JF.initialize( {apiKey: "d9b0f3e377ac5108046699b43efebbd1"} );


        JF.login(

            function success(){

                window.alert("Authorized");

            },

            function error(){

                window.alert("Could not authorize user");

            }

        );

            var formID= "73422511684151";

            JF.getForm(formID, function(response){

                    document.getElementById("counter").innerHTML=response.count;

            }

       );

    </script>

    </body>

    </html>


    It correctly displays the submission count of your form:

    15131762971.png

  • Profile Image
    nhamwey
    Answered on December 13, 2017 at 01:50 PM

    Thank you so much.

    I removed the window alert and it seems to be functioning properly on my end, is it needed?

    This is what I took out:

    JF.login(


            function success(){


                window.alert("");


            },


            function error(){


                window.alert("Could not authorize user");


            }


        );


    You guys have been great help so I dont want this to come off the wrong way, but do paying users get their questions answered faster? I probably will be purchasing a plan soon regardless, but if there is like a live chat help kind of thing, I might do it sooner

  • Profile Image
    BDAVID
    Answered on December 13, 2017 at 03:59 PM

    I am not an expert on the use of the API(we have an API team for this matter), but I don't find the need of those functions you took out, as they are just windows alerts, and if you have confirmed that it works in your end without them, then it is safe to say that those are not needed. 

    On regards of your questions "do paying users get their questions answered faster?", the answer is No. We answer forum questions in order of arrival. 

    We have chat support, but we open chat only for the most active paid users during the latest 30 days, and we still require them to open a thread if their concerns required further testing.

  • Profile Image
    nhamwey
    Answered on December 15, 2017 at 11:30 AM

    Thanks for the response.

    I have one more question on this.

    How do I reference the "count" from multiple forms on one page and/or reference the count from one form in multiple places on one page?

  • Profile Image
    Kevin_G
    Answered on December 15, 2017 at 01:07 PM

    How do I reference the "count" from multiple forms on one page and/or reference the count from one form in multiple places on one page?

    If you're still using the code above, then yes, you may simply load the API resources and then embed the counter's code anywhere you want. 

    If you're using the submissions counter widget then no, the widget will work where the form has been embedded only. 

    I hope this helps. 

  • Profile Image
    nhamwey
    Answered on December 15, 2017 at 01:14 PM

    Yes, the code above works fine, but it only works once on a page.


    It only loads the count where the <div id="counter"> is highest up on the page.

    Then there is the issue of referencing that count from a variety of forms.

  • Profile Image
    BDAVID
    Answered on December 15, 2017 at 02:41 PM

    You may contact our API team api@jotform.com to see if there is a way to know from which page the count comes from. 

  • Profile Image
    BDAVID
    Answered on December 15, 2017 at 02:43 PM

    Just to let you know, if you need to see in your form submissions from which page the form was submitted, then you can add the "Get Form Page URL": https://widgets.jotform.com/widget/get_form_page_url