title: Uncaught TypeError: Cannot set property 'value' of > null" in Android
body: <p>I try to update information through <code>java script code in Android side</code>.</p>
  
  <p>On Android version 4.3, it's work.</p>
  
  <p>But Android version 4.4, it appeared these error, so can not update information.</p>
  
  <blockquote>
    <p>[INFO:CONSOLE(1)] "Uncaught TypeError: Cannot set property 'value' of
    null", source:  (1) I/chromium﹕ [INFO:CONSOLE(1)] "Uncaught TypeError:
    Cannot set property 'value' of null", source:  (1) I/chromium﹕
    [INFO:CONSOLE(1)] "Uncaught TypeError: Cannot call method 'submit' of
    null", source:  (1)</p>
  </blockquote>
  
  <p>I know from Android version 4.4, already used new <a href="http://readwrite.com/2013/11/07/android-kitkat-developers-users" rel="nofollow"><code>Web View</code></a> to support, but i don't know where is main issue.</p>
  
  <p>People who know how to update information successfully via Java script code even on Android 4.4,</p>
  
  <p>Please tell me,</p>
  
  <p>Thanks you,</p>
  
  <p>p/s : Codes</p>
  
  <pre><code>// Load Web View to update new SSID, Security Key, Security Mode
              WebView mWv = new WebView(this);
              // Simplest usage: note that an exception will NOT be thrown
              // if there is an error loading this page (see below).
  
              mWv.loadUrl("http://" + Constants.IP + "/cgi-bin/input");
  
              mWv.getSettings().setJavaScriptEnabled(true);
              mWv.getSettings().setDomStorageEnabled(true);
  
              mWv.setWebChromeClient(new WebChromeClient());
  
              mWv.setWebViewClient(new WebViewClient(){
                  public void onPageFinished(WebView mWv, String url) {
                      super.onPageFinished(mWv, url);
  
                      /**
                       * Pass parametes :
                       * - New SSID
                       * - New Security Key
                       * - Display raw picture
                       */
                      // @"document.getElementsByName('%@')[0].value='%@'"
                      mWv.loadUrl("javascript:document.getElementById('wifi_ssid').value='" +
                                          mEtSSID.getText().toString() + "'");
  
                      if (mEtSecurityKey.length() == 0
                              | Utils.checkValidatePassword(mEtSecurityKey, 8)) {
                          mWv.loadUrl("javascript:document.getElementById('wifi_key').value='" +
                                              mEtSecurityKey.getText().toString() + "'");
  
                          if (mCbDisplayRawPicture.isChecked())
                              mWv.loadUrl(
                                      "javascript:document.getElementById('displayraw').value='checked'");
                          else
                              mWv.loadUrl("javascript:document.getElementById('displayraw').value=''");
  
                          // @"document.forms['sendForm'].submit()"
                          mWv.loadUrl("javascript:document.getElementById('sendForm').submit()");
  
                          /**
                           * Also get new SSID and new Security Key in Card Setting page
                           */
                          IS_BACK_FROM_CHANGE_SSID_AND_SCCURITY_KEY_TO_CARD_SETTING_PAGE = true;
  
                          /**
                           * Finish current Change SSID And Security Key after submit success
                           */
                          finish();
                      } else
                          Toast.makeText(SettingAndReviewSettingPage.this,
                                         getString(R.string.toast_your_password_is_case_sensitive),
                                         Toast.LENGTH_SHORT).show();
                  }
                  public boolean shouldOverrideUrlLoading(WebView view, String url) {
                      view.loadUrl(url);
                      return true;
                  }
  
              });
  </code></pre>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>I surprised when I find out the solution. I need define the variables for Java script codes. Like following code &amp; it worked.</p>
  
  <pre><code>mWv.setWebViewClient(new WebViewClient(){
                  public void onPageFinished(WebView mWv, String url) {
                      super.onPageFinished(mWv, url);
  
                      /**
                       * Pass parametes :
                       * - New SSID
                       * - New Security Key
                       * - Display raw picture
                       */
                      // @"document.getElementsByName('%@')[0].value='%@'"
  
                      mWv.loadUrl("javascript:var x = document.getElementById('wifi_ssid').value = '" +
                                          mEtSSID.getText().toString() + "';");
  
                      // need check password is correct or not
                      // - empty or minimum has 8 characters.
                      // - have both character &amp; number in typed password
                      if ((mEtSecurityKey.length() == 0
                              | Utils.checkValidatePassword(mEtSecurityKey, 8)
                              &amp; Utils.checkValidatePassword(mEtSecurityKey.getText().toString()))) {
                          mWv.loadUrl("javascript:var y = document.getElementById('wifi_key').value = '" +
                                              mEtSecurityKey.getText().toString() + "';");
  
                          if (mCbDisplayRawPicture.isChecked())
                              mWv.loadUrl("javascript:var z = document.getElementById('displayraw').value='checked'");
                          else
                              mWv.loadUrl("javascript:var z = document.getElementById('displayraw').value=''");
  
                          // @"document.forms['sendForm'].submit()"
                          // mWv.loadUrl("javascript:console.log('sendForm: '+document.getElementById('sendForm').value);");
                          mWv.loadUrl("javascript:document.getElementById('sendForm').submit()");
  
                          /**
                           * Also get new SSID and new Security Key in Card Setting page
                           */
                          IS_BACK_FROM_CHANGE_SSID_AND_SCCURITY_KEY_TO_CARD_SETTING_PAGE = true;
  
                          /**
                           * Finish current Change SSID And Security Key after submit success
                           */
                          finish();
                      } else
                          Toast.makeText(
                                  ChangeSSIDAndPasswordPage.this,
                                  getString(R.string.toast_your_password_is_case_sensitive),
                                  Toast.LENGTH_SHORT).show();
                  }
                  public boolean shouldOverrideUrlLoading(WebView view, String url) {
                      view.loadUrl(url);
                      return true;
                  }
              });
  </code></pre>