title: javascript onclick not working for android app
body: <p>I'm trying to develop an android app using eclipse and phonegap. The app is a basic lighting calculator using javascript. I'm trying to call to the javascript function in the head of the document with an onclick to calculate the result. I believe the problem may be in the onclick=, onblur=, or onfocus=. My project is time sensitive any help would be greatly appreciated. Below is my code and here is a link to a stand alone page showing the code working. <a href="http://www.everlastlight.com/energy_calc.html" rel="nofollow">http://www.everlastlight.com/energy_calc.html</a>   </p>
  
  <pre><code>&lt;!DOCTYPE html&gt; 
  &lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; 
  &lt;title&gt;EverLast&amp;reg; Lighting&lt;/title&gt; 
  &lt;link rel="stylesheet"  href="../../css/themes/default/jquery.mobile-1.1.1.css" /&gt; 
  &lt;link rel="stylesheet" href="../_assets/css/jqm-docs.css"/&gt;
  &lt;!--&lt;script src="../../js/calc.js"&gt;&lt;/script&gt;--&gt;
  &lt;script src="../../js/jquery.js"&gt;&lt;/script&gt;
  &lt;script src="../../docs/_assets/js/jqm-docs.js"&gt;&lt;/script&gt;
  &lt;script src="../../js/jquery.mobile-1.1.1.js"&gt;&lt;/script&gt;
      &lt;!--&lt;script src="../../docs/_assets/js/calc1.js"&gt;--&gt;
   &lt;/script&gt;
  &lt;script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
  function Calculate1()
  {
              var no_fixtures1, hrs_yr1, cost_kwh1, watts1_1, watts2_1, invst1;
              var s_perfix$1, s_sitecost1_1, s_sitecost2_1, s_sav_yr1, s_recoup1, s_res1, s_res2_1;
  
                                              no_fixtures1 = document.basicecalc.no_fixtures1.value;
                                              hrs_yr1 = document.basicecalc.hrs_yr1.value;
                                              cost_kwh1 = document.basicecalc.cost_kwh1.value;
                                              watts1_1 = document.basicecalc.watts1_1.value;
                                              watts2_1 = document.basicecalc.watts2_1.value;
                                              invst1 = document.basicecalc.invst1.value;
  
                                              if ( watts1_1 == "" )
                                                              {alert("Please enter the wattage of the existing fixture");
                                                                              return;}
  
                                              //if ( watts2_1 == "" )
        //                  {alert("Please enter the wattage of the proposed fixture");
                                                                              //return;}
                                             else if ( no_fixtures1 == "" )
                              {alert("Please enter the number of fixtures at the site");
                              return;  }
           else{
                                                              s_perfix$1 = Math.round((watts1_1 - watts2_1)*(hrs_yr1)*(cost_kwh1)/10)/100;
                                                              s_sitecost1_1 = Math.round((watts1_1)*(hrs_yr1)*(no_fixtures1)*(cost_kwh1)/10)/100;
                                                              s_sitecost2_1 = Math.round((watts2_1)*(hrs_yr1)*(no_fixtures1)*(cost_kwh1)/10)/100;
                                                              s_sav_yr1 = Math.round((s_sitecost1_1-s_sitecost2_1)*100)/100;
  
                                                              s_res1 =(invst1/s_perfix$1)
  
  
                                                                              document.basicecalc.s_perfix$1.value   = "$"+ s_perfix$1;
                                                                              document.basicecalc.s_sitecost1_1.value = "$"+ s_sitecost1_1;
                                                                              document.basicecalc.s_sitecost2_1.value = "$"+ s_sitecost2_1;
                                                                              document.basicecalc.s_sav_yr1.value = "$"+ s_sav_yr1;
  
  
                                                                              if(invst1 !=="")
                                                                              {document.basicecalc.s_recoup1.value = Math.round(s_res1*12) + " months ("+ Math.round(s_res1*100)/100 + " yr.)";
                                                                              }
  
                                                              }
  
  }
  
  function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
  }
  
  function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))&gt;0&amp;&amp;parent.frames.length) {
  d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&amp;&amp;d.all) x=d.all[n]; for (i=0;!x&amp;&amp;i&lt;d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&amp;&amp;d.layers&amp;&amp;i&lt;d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
  }
  
  function MM_validateForm() { //v3.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i&lt;(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
  if (val) { nm=val.name; if ((val=val.value)!="") {
    if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
      if (p&lt;1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
    } else if (test!='R') { num = parseFloat(val);
      if (val!=''+num) errors+='Please use only numbers.';
      if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
        min=test.substring(8,p); max=test.substring(p+1);
        if (num&lt;min || max&lt;num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
  } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert(errors);
  document.MM_returnValue = (errors == '');
  }
  &lt;/script&gt;   
  &lt;/head&gt; 
  &lt;body&gt; 
  &lt;div data-role="page" class="type-interior"&gt;
  
  &lt;div data-role="header" data-theme="f"&gt;
      &lt;h1&gt;EverLast&amp;reg;&lt;/h1&gt;
      &lt;a href="../../" data-icon="home" data-iconpos="notext" data-direction="reverse"&gt;Home&lt;/a&gt;
      &lt;a href="../nav.html" data-icon="search" data-iconpos="notext" data-rel="dialog" data-transition="fade"&gt;Search&lt;/a&gt;
  &lt;/div&gt;&lt;!-- /header --&gt;
  
  &lt;div data-role="content"&gt;
  
      &lt;div class="content-primary"&gt;
  
      &lt;h2&gt;Basic Energy Calculator&lt;/h2&gt;
  
      &lt;p&gt;
  &lt;div style="padding-right:0px;"&gt;
  &lt;p&gt;Calculate energy savings by relamping your lighting system.&lt;br&gt;Also calculate the return on investment of the new system.&lt;br&gt;&lt;br&gt;Fill in all the fields and click "calculate".&lt;br&gt;&lt;b&gt;Your results will display below.&lt;/b&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;!--/body head :: Head Type B Ended --&gt;
  
  
  
  &lt;!-- main body --&gt;
  
  
  &lt;form name="basicecalc"&gt;
  
  
  &lt;!-- table 1 (user inputs) --&gt;
  &lt;div&gt;
  &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
  &lt;tr&gt;
  &lt;td colspan="3"&gt;&lt;span class="orange"&gt;*&lt;/span&gt; Required&lt;br&gt; &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;span class="orange"&gt;*&lt;/span&gt; Quantity of fixtures:  &lt;/td&gt;
  &lt;td&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" style="text-align:right" name="no_fixtures1" maxlength="6" size="6" value="1"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;span class="orange"&gt;*&lt;/span&gt; Average operating hours per year:  &lt;/td&gt;
  &lt;td&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" style="text-align:right" name="hrs_yr1" maxlength="6" size="6" value="4500"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;span class="orange"&gt;*&lt;/span&gt; Cost per kilowatt hour:  &lt;/td&gt;
  &lt;td&gt;$&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" style="text-align:right" name="cost_kwh1" maxlength="6" size="6" value="0.10"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;span class="orange"&gt;*&lt;/span&gt; Watts (per fixture) used in existing system:  &lt;/td&gt;
  &lt;td&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" style="text-align:right" name="watts1_1" maxlength="6" size="6" onblur="MM_validateForm('watts1_1','','NisNum');return document.MM_returnValue"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;span class="orange"&gt;*&lt;/span&gt; Watts (per fixture) used in new system:  &lt;/td&gt;
  &lt;td&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" style="text-align:right" name="watts2_1" maxlength="6" size="6"   onblur="MM_validateForm('watts2_1','','NisNum');return document.MM_returnValue"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;&lt;span class="orange"&gt;*&lt;/span&gt;Cost to upgrade each fixture:  &lt;/td&gt;
  &lt;td&gt;$&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" style="text-align:right" name="invst1" maxlength="6" size="6" onblur="MM_validateForm('invst1','','NisNum');return document.MM_returnValue"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td colspan="2"&gt; &lt;/td&gt;
  &lt;td align="right"&gt; &lt;input name="calcbtn" type="button" class="calcbtn" title="Calculate" value="Calculate" onclick="Calculate1()"&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;
  &lt;a href="javascript:MM_callJS('Calculate1()');" data-role="button"&gt;Calculate&lt;/a&gt;
  &lt;/div&gt;
  &lt;!-- / table 1 (user inputs) --&gt;
  &lt;hr&gt;
  &lt;br&gt;
  &lt;div class="resultsLabel"&gt;Results&lt;/div&gt;
  
  
  
  &lt;!-- table 2 (results) --&gt;
  &lt;div class="resultsBlock"&gt;
  &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
  &lt;tr&gt;
  &lt;td valign="top"&gt;
  &lt;br&gt;
  &lt;div&gt;&lt;b&gt;Cost of Electricity:&lt;/b&gt;&lt;/div&gt;
      &lt;!-- table 2a --&gt;
      &lt;div&gt;
  
      &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
      &lt;tr&gt;
      &lt;td&gt;Current system:  &lt;/td&gt;
      &lt;td align="right"&gt;&lt;input type="text" style="text-align:right" class="result" name="s_sitecost1_1" maxlength="8" readOnly onfocus="this.blur()" size="8"&gt;           &lt;/td&gt;
      &lt;td&gt;&amp;nbsp;/yr.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Proposed system:&lt;/td&gt;
  
      &lt;td align="right"&gt;&lt;input type="text" style="text-align:right" class="result" name="s_sitecost2_1" maxlength="8" readOnly onfocus="this.blur()" size="8" onblur="MM_validateForm('s_sitecost2_1','','NisNum');return document.MM_returnValue"&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;/yr.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/div&gt;
      &lt;!-- / table 2a --&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;div&gt;&lt;b&gt;Energy Savings (with proposed system)&lt;/b&gt;&lt;/div&gt;
  
      &lt;!-- table 2b --&gt;
      &lt;div&gt;
      &lt;table border="0" cellpadding="0" cellspacing="0" width="100%"&gt;
      &lt;tr&gt;
      &lt;td&gt;Each fixture:&lt;/td&gt;
      &lt;td align="right"&gt;&lt;input type="text" style="text-align:right" class="result" name="s_perfix$1" maxlength="8" readOnly onfocus="this.blur()" size="8"&gt;      &lt;/td&gt;
      &lt;td&gt;&amp;nbsp;/yr.&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Total:&lt;/td&gt;
      &lt;td align="right"&gt;&lt;input type="text" style="text-align:right" class="result" name="s_sav_yr1" maxlength="10" readOnly onfocus="this.blur()" size="8"&gt;   &lt;/td&gt;
      &lt;td&gt;&amp;nbsp;/yr.&lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/div&gt;
      &lt;div style="margin-top:12px;"&gt;* This cost should include the lamp, ballast, and labor required to replace the fixture. You may want to subtract any costs that would have been incurred with the current system.&lt;/div&gt;
  &lt;/tr&gt;
  
  &lt;/table&gt;        
  
      &lt;/p&gt;
  
  
      &lt;/div&gt;&lt;!--/content-primary --&gt;      
  
      &lt;div class="content-secondary"&gt;
  
          &lt;div data-role="collapsible" data-collapsed="true" data-theme="b" data-content-theme="d"&gt;
  
                  &lt;h3&gt;More in this section&lt;/h3&gt;
  
                  &lt;ul data-role="listview"  data-theme="c" data-dividertheme="f"&gt;
              &lt;li data-role="list-divider"&gt;Overview&lt;/li&gt;
              &lt;li&gt;&lt;a href="watts.html"&gt;Watts Per Sq. Ft.&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="lightinglayout.html"&gt;Lighting Layout&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="fixreplace.html"&gt;Fixture Replacement&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="dimming.html"&gt;Dimming Watts&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="costwait.html"&gt;Cost of Waiting&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="samplelife.html"&gt;Simple Life Cycle&lt;/a&gt;&lt;/li&gt;
  
                  &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;      
  
  &lt;/div&gt;&lt;!-- /content --&gt;
  
  &lt;div data-role="footer" class="footer-docs" data-theme="c" align="center"&gt;
          &lt;p&gt;&amp;copy; 2012 EverLast&amp;reg;. All Rights Reserved.&lt;/p&gt;
  &lt;/div&gt;  
  </code></pre>
  
  <p></p>
  
  <p>
  </p>