Can I insert JavaScript code in the Submit button

  • micici
    Asked on April 4, 2016 at 8:58 AM

    Hello,

     

    I would like to know if it's possible, and if yes, how, to add code to my "Submit" button in my form.

    The point is to add action, on top of sending the form.

    Ideally, I would like to do that on my page and not on the form self to avoid making a lot of different form for each different actions I would llike to add to the button.

     

    I hope I was clear enough with my question..

     

    Best Regards,

  • Welvin Support Team Lead
    Replied on April 4, 2016 at 11:09 AM

    For security reasons, we restrict adding scripts in the form so what you can do would be to get the form source codes and modify the source codes before embedding it to your website.

    https://www.jotform.com/help/104-How-to-get-the-Full-Source-Code-of-your-Form 

    You can save the source as an HTML and then you can embed the HTML file as an iframe to your page. Of course, you have to upload the HTML first to your own server.

  • micici
    Replied on April 5, 2016 at 9:45 AM
    Hello,
    Thank you for your answer.I found a way to simulate the click on the "Sending" button on my page, so my problem is partially solved.
    Now I need to hide the button from my page, without deleting it or else I can't simulate its click.
    I tried to put its display to none but oddly it doesn't work..document.getElementById('60892377133359').contentWindow.document.getElementById("input_2").style.display = "none";
    Do you have a solution to hide the button?
    Thanks.
    Cordialement,
    Cindy, MiCICI
    www.micici.fr

    ...
  • Welvin Support Team Lead
    Replied on April 5, 2016 at 10:51 AM

    That's great to know. As for hiding the submit button, I needed to move it to a new thread. Please find my answer to that question in this thread: https://www.jotform.com/answers/810837