title: Programmatically fill in data in a UIWebview
body: <p>In my app, I want to be able to have the user enter their login info in a custom view and then show a UIWebView.  I want the UIWebView to be programmatically filled in with the user's username and password.  Then the UIWebView should programmatically click the login button.  I've been trying:</p>
  
  <pre><code>[webView stringByEvaluatingJavaScriptFromString:@"document.L_lbsc_txtUserName.text.value='ANdrew';"];
  </code></pre>
  
  <p>but its not working.  I don't really understand how <code>stringByEvaluatingJavaScriptFromString</code> works or what it's designed to do.</p>
  
  <p>I think it might have something to do with what I filled in the string field above.
  Here is the source code of the website I'm trying to access:</p>
  
  <pre><code>&lt;div class="lgntxt"&gt;
    &lt;div style="padding-left:3px;"&gt;
      &lt;input name="L$lbsc$txtUserName" type="text" value=" -username-" size="10" id="L_lbsc_txtUserName" tabindex="1" class="textbox" onfocus="if(this.value == ' -username-') this.value = ''; Hide('L_lbsc_txtPasswordHelp'); Show('L_lbsc_txtPassword');" onblur="if(this.value == '') this.value = ' -username-';" style="width:80px;"&gt;&lt;br&gt;
      &lt;img src="/podium/images/spacer.gif" border="0" width="3" height="1"&gt;&lt;br&gt;
      &lt;input name="L$lbsc$txtPasswordHelp" type="text" value=" -password-" size="10" id="L_lbsc_txtPasswordHelp" tabindex="1" class="textbox" onfocus="Hide('L_lbsc_txtPasswordHelp'); Show('L_lbsc_txtPassword'); document.getElementById('L_lbsc_txtPassword').focus();" style="width:80px;display:;"&gt;
      &lt;input name="L$lbsc$txtPassword" type="password" size="10" id="L_lbsc_txtPassword" tabindex="2" class="textbox" onkeydown="if ((event.which ? event.which : event.keyCode) == 13) {return false;};" onkeyup="if ((event.which ? event.which : event.keyCode) == 13) {__doPostBack('L$lbsc$btnLogin','');return false;};" onblur="if(this.value == '') {Show('L_lbsc_txtPasswordHelp'); Hide('L_lbsc_txtPassword');}" style="width:80px;display:none;"&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm trying to replace the username and password fields.</p>
  
  <p>Any help would be greatly appreciated.
  Thanks in advance.</p>
  
  <p><strong>EDIT</strong>
  so I've tried these and none of them work:</p>
  
  <pre><code>[webView stringByEvaluatingJavaScriptFromString:@"document.myForm.myText.value='text from Obj-C';"];
  
  [webView stringByEvaluatingJavaScriptFromString:@"document.getElementById('L$lbsc$txtUserName').value='ANdrew';"];
  </code></pre>