title: "Undefined" when passing data to JavaScript from Android
body: <p>I'm using this code but the value said "undefined" can anyone point me the problem?</p>
  
  <p>this is my java class codes</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(com.frux.web.R.layout.activity_main);
      String value = "Isiah";
      WebView web = (WebView) findViewById(R.id.web1);
      web.getSettings().setJavaScriptEnabled(true);
      web.loadUrl("file:///android_asset/www/index.html");
      web.loadUrl("javascript:setValue(\""+ value +"\")");
  
  
  }
  </code></pre>
  
  <p>and this is my webpage codes</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  Whats your Name?
  &lt;input id="name" value="" /&gt;
  &lt;button onclick = "setValue()"&gt;Submit&lt;/button&gt;
  
  &lt;script type="text/javascript"&gt; 
  function setValue(value){
  var myValue = value;
  document.getElementById("name").value = myValue;
  
  }
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I also try this one </p>
  
  <pre><code>web.loadUrl("javascript:setValue('"+ value +"')");
  </code></pre>
  
  <p>any thoughts will be highly appreciated</p>
  
  <p>I used the codes in this HTML codes and its display nothing unlike the other codes above that I post.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  
  
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;script type="text/javascript"&gt;  
  
  function setValue(amount1)
  {
      myValue = amount1;
      document.getElementById("amount").value = myValue;
    }
  
  function rand ( n )
  {
      document.getElementById("orderRefId").value =  ( Math.floor ( Math.random ( ) * n + 1 ) );
  }
  
  
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onLoad="rand(200000);setValue();"&gt;
          &lt;!-- 
              Note: https://www.pesopay.com/b2c2/eng/payment/payForm.jsp for live payment URL
                    https://test.pesopay.com/b2cDemo/eng/payment/payForm.jsp for test payment URL
          --&gt;
          &lt;form method="POST" name="frmPayment" action="https://test.pesopay.com/b2cDemo/eng/payment/payForm.jsp"&gt;
          &lt;table&gt;
          &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td&gt;Order Reference No. (your reference number for every transaction that has transpired):&lt;/td&gt; 
              &lt;td&gt;&lt;input type="text" id="orderRefId" name="orderRef" value="Test-001"/&gt;&lt;/td&gt;
          &lt;/tr&gt;   
          &lt;tr&gt;
              &lt;td&gt;Amount:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="amount" id="amount" value=""/&gt;&lt;/td&gt;
  
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Currency Code - "608" for Philippine Peso, "840" for US Dollar:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="currCode" value="608"/&gt;&lt;/td&gt;
          &lt;/tr&gt;   
          &lt;tr&gt;
              &lt;td&gt;Language:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="lang" value="E"/&gt;&lt;/td&gt;
          &lt;/tr&gt;   
          &lt;tr&gt;
              &lt;td&gt;Merchant ID (the merchant identification number that was issued to you - merchant IDs between test account and live account are not the same):&lt;/td&gt; 
              &lt;td&gt;&lt;input type="text" name="merchantId" value="18056869"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;    
              &lt;td&gt;Redirect to a URL upon failed transaction:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="failUrl" value="http://www.yahoo.com?flag=failed"/&gt;&lt;/td&gt;
          &lt;/tr&gt;   
          &lt;tr&gt;
              &lt;td&gt;Redirect to a URL upon successful transaction:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="successUrl" value="http://www.google.com?flag=success"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Redirect to a URL upon canceled transaction:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="cancelUrl" value="http://www.altavista.com?flag=cancel"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Type of payment (normal sales or authorized i.e. hold payment):&lt;/td&gt; 
              &lt;td&gt;&lt;input type="text" name="payType" value="N"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;    
              &lt;td&gt;Payment Method - Change to "ALL" for all the activated payment methods in the account, Change to "BancNet" for BancNet debit card payments only, Change to "GCASH" for GCash mobile payments only, Change to "CC" for credit card payments only:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="payMethod" value="ALL"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;    
              &lt;td&gt;Remark:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="remark" value="Asiapay Test"/&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;!--&lt;tr&gt;    
              &lt;td&gt;Redirect:&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name="redirect" value="1"/&gt;&lt;/td&gt;
          &lt;/tr&gt;--&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;/td&gt;
          &lt;/tr&gt;   
  
          &lt;input type="submit" value="Submit"&gt;
  
  
  
  
          &lt;/tbody&gt;
          &lt;/table&gt;    
  
  
          &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;             
  </code></pre>