Getting a null error when adding script with form

  • Profile Image
    TSMProduction
    Asked on January 08, 2013 at 05:22 PM

    I am trying to change some values on a page load. 

    I am using this code to achieve this:

    $(document).ready(function(){

    $("#input_5").append("<option>This is new</option>");

    });

    I get this error when I load the page:

    "'null'" is not an object"

    I only get this error when the script "http://max.jotfor.ms/min/g=jotform?3.1.1316" is loaded on the page. Is there anything that would be conflicting with this? I see that it's not finding the id "input_5". 

     

    Thanks for your time!

  • Profile Image
    jeanettebmz
    Answered on January 08, 2013 at 05:43 PM

    There is a conflict with this jquery line of code

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

    Please insert right after this code, the following line:
    <script>jQuery.noConflict();</script>


    I hope this helps
  • Profile Image
    TSMProduction
    Answered on January 09, 2013 at 10:02 AM

    Thank you for the response. I placed the script right after the jquery library but it does not seem to be working. I get the error "'undefined' in not a function".

  • Profile Image
    jeanettebmz
    Answered on January 09, 2013 at 10:06 AM

    Can you please explain what is the action that makes you to get this error? I open the URL where the form is shown, and we would like to reproduce the error

  • Profile Image
    TSMProduction
    Answered on January 09, 2013 at 10:29 AM

    I am trying to add a new option to the dropdown menu as soon as the page loads. I'm using the Chrome console to catch the errors on the page load. 

    The URL that I posted is just me testing to see if I could actually achieve this. 

    I attached a screenshot of the error in chrome:

  • Profile Image
    abajan
    Answered on January 09, 2013 at 11:32 AM

    @TMSProduction

    Upon viewing the page's source, I noticed that the type attribute is missing in your custom scripts' tags. Although it's not required in HTML5, speaking under correction, I beleive it is required in pages having an XHTML doctype (even transitional ones). Including the attribute may not solve the problem but insert it anyway to be on the safe side. I'm pretty sure it's a conflict between Prototype and jQuery that's the main cause of problem though.

  • Profile Image
    abajan
    Answered on January 09, 2013 at 11:50 AM

    Hi again,

    The following video may also be helpful:

    (It's advisable to view it fullscreen in HD: Either 720p or 1080p)

  • Profile Image
    abajan
    Answered on January 09, 2013 at 12:46 PM

    Hi again,

    Using the video as a guide, I was able to fix the issue. Please view the source of this demo for the solution.

  • Profile Image
    TSMProduction
    Answered on January 09, 2013 at 01:26 PM

    That does the trick! Thanks so much for solving that. 

  • Profile Image
    abajan
    Answered on January 09, 2013 at 01:29 PM

    Glad we could help :)

    Do let us know if there's anything else with which you may need assistance.