Jotform Iframe getElementbyID

  • Profile Image
    morriswu
    Asked on December 07, 2012 at 07:35 AM

    Hi guys, I'm trying to use javascript to prepoulate a value for a jotform form. I am using the iframe version of it, but when I run the code, I get the error, "Uncaught TypeError: Cannot call method 'getElementById' of undefined "

     Here's what my javascript look like, and what my iframe code looks like : 

     

        <script type='text/javascript'>

         $(window).load(function() {

               document.getElementById('jotform').document.getElementById('input_13').value = "<?=htmlspecialchars($_POST['input_13'], ENT_COMPAT)?>";

     

         });

      </script>

          <iframe  id="jotform" allowtransparency="true" src="//form.jotform.me/form/20988888993483" frameborder="0" style="width:100%; height:584px; border:none;" scrolling="no">
    </iframe>
  • Profile Image
    NeilVicente
    Answered on December 07, 2012 at 07:44 AM

    Prefill the form using URL parameters instead. For example:

    <iframe  id="jotform" allowtransparency="true" src="//form.jotform.me/form/20988888993483?numberOf=<?=htmlspecialchars($_POST['input_13'], ENT_COMPAT)?>" frameborder="0" style="width:100%; height:584px; border:none;" scrolling="no">
    </iframe>

    numberOf is the input name of that particular text box. For more information on how to construct URL parameters for prepopulation, visit the following link:

    http://www.jotform.com/help/71-Prepopulating-the-fields-to-your-JotForm-via-URL-parameters