Getting focus on a data field on google sites

  • Profile Image
    plantsguy
    Asked on February 21, 2017 at 05:57 PM

    I need the first and only field to have focus on loading the website so I can utilize a barcode scanner without the user having to select the data field.  I have successfully embedded the Jotform https://form.jotform.com/70477876189172

    into https://sites.google.com/site/scanscaletickets/, and it is working but I cannot get the focus to work using the code I have found in this forum.... 

     

  • Profile Image
    Chriistian
    Answered on February 21, 2017 at 11:01 PM

    Hi,

    To be able get focus on the field when your form loads on the site, you need first to get the full source code of your form and embed to your site. After that, based from your form the field id is input_5. Please remove the # on #input_5.Can you please try this code below and see if this works?

    <script>

    document.observe("dom:loaded", function() {

      $('input_5).focus();

    });

    </script>

     

    And also, please make sure that your browser is allowed to load JavaScript codes.

    Hope this helps.

    Regards

     

  • Profile Image
    plantsguy
    Answered on February 22, 2017 at 10:56 AM

    I appreciate the help, but I just cant seem to get it to work.  I have tried Google Chrome, IE11, and safari on my iphone.

     

    Javascript is enabled, and I copied the source code into the HTML box.  The form submits fine, but no focus.

    Has anyone ever done this on Google Sites (classic)?..the newest Google sites uses a Gadget, which doesn't seem to allow editing of the code

  • Profile Image
    david
    Answered on February 22, 2017 at 01:46 PM

    It seems your filed ID in the embedded form is the following:

    input_5-caja-guest-0___

    Try using that instead of input_5 in your script.