title: Uncaught ReferenceError: MyFunction is not defined - PhoneGap
body: <p>I'm using PhoneGap and jQuery Mobile for a mobile web app. When I try to run MyFunction that is set on a onclick attribute then I get an error in the console that </p>
  
  <blockquote>
    <p>Uncaught ReferenceError: MyFunction is not defined.</p>
  </blockquote>
  
  <p>This is my code:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
   &lt;title&gt;Product&lt;/title&gt;
  
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  
  &lt;link rel="stylesheet" type="text/css" href="css/index.css" /&gt;
  &lt;link rel="stylesheet" href="css/jquery.mobile-1.3.1.min.css" /&gt;
  &lt;script type="text/javascript" src="cordova-2.7.0.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/index.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/jquery.mobile-1.3.1.min.js"&gt;&lt;/script&gt;
  
  
  
  &lt;!--Generation Script Starts here --&gt;
  &lt;script type="text/javascript"&gt;
  function makeid()
  {
      var text = "";
      var possible = "123456789";
  
      for( var i=0; i &lt; 4; i++ )
          text += possible.charAt(Math.floor(Math.random() * possible.length));
  
      return text;
  }
  
  function makeid1()
  {
      var text1 = "";
      var possible = "123456789";
  
      for( var i=0; i &lt; 1; i++ )
          text1 += possible.charAt(Math.floor(Math.random() * possible.length));
  
      return text1;
  }
  
  function makeid2()
  {
      var text2 = "";
      var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
      for( var i=0; i &lt; 1; i++ )
          text2 += possible.charAt(Math.floor(Math.random() * possible.length));
  
      return text2;
  }
  
  function makeid3()
  {
      var text3 = "";
      var possible = "123456789";
  
      for( var i=0; i &lt; 2; i++ )
          text3 += possible.charAt(Math.floor(Math.random() * possible.length));
  
      return text3;
  }
  
  function myFunction()
  {
                document.getElementById("demo").innerHTML="D01E-BOA0-" + makeid() + "-" + makeid1() + makeid2() + makeid3();
  }
  
  &lt;/script&gt;
  &lt;!-- Generation Script Ends Here --&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div data-role="page"&gt;
  
  &lt;div data-role="header" data-theme="b"&gt;
      &lt;a href="index.html" data-role="button" data-icon="home" data-iconpos="notext" data-theme="b" data-iconshadow="false" data-inline="true"&gt;Home&lt;/a&gt;
      &lt;h1&gt;Product&lt;/h1&gt;
  &lt;/div&gt;&lt;!-- /header --&gt;
  
  &lt;div data-role="content"&gt;
  
  
      &lt;p id="demo" style="text-align:center;"&gt;&lt;/p&gt;
  
      &lt;input type="button" onclick="myFunction()" value="Generate!" data-theme="b"&gt;
  &lt;/div&gt;&lt;!-- /content --&gt;
  
  
  &lt;/div&gt;&lt;!-- /page --&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>