title: Autofill UIWebView
body: <p>I've been looking around, and have found  lot of code for autofilling that looks like:</p>
  
  <pre><code> - (void)webViewDidFinishLoad:(UIWebView *)webView
  {
  //For Authentication
  NSString *savedUsername = @"Bapu";
  NSString *savedPassword = @"Bapu123";
  
  if (savedUsername.length != 0 &amp;&amp; savedPassword.length != 0)
  {
      //create js strings
      NSString *loadUsernameJS = [NSString stringWithFormat:@"var inputFields = document.querySelectorAll(\"input[type='text']\"); \
                                  for (var i = inputFields.length &gt;&gt;&gt; 0; i--;) { inputFields[i].value = '%@';}", savedUsername];
      NSString *loadPasswordJS = [NSString stringWithFormat:@"var inputFields = document.querySelectorAll(\"input[type='password']\"); \
                                  for (var i = inputFields.length &gt;&gt;&gt; 0; i--;) { inputFields[i].value = '%@';}", savedPassword];
  
      //autofill the form
      [webView stringByEvaluatingJavaScriptFromString: loadUsernameJS];
      [webView stringByEvaluatingJavaScriptFromString: loadPasswordJS];
  }
  }
  </code></pre>
  
  <p>And that's what I have in my .m, however, when I go to the webView, the fields remain blank. Any clues as to why it cannot fill?</p>
  
  <p>If it helps, the website I am trying to fill is: sis.ocsarts.net, and the relevant code is:</p>
  
  <pre><code>input type="text" size="20" name="UserName" value=""  onkeydown="if (event.keyCode==13) { document.frmLogin.submit(); return false; };"
  </code></pre>
  
  <p>And</p>
  
  <pre><code>input type="password" size="20" name="Password"  onkeydown="if (event.keyCode==13) { document.frmLogin.submit(); return false; };"
  </code></pre>
  
  <p>The full code for my FirstViewController.m is:</p>
  
  <pre><code>//
  //  FirstViewController.m
  //  OCSA
  //
  //  Created by Jack Kearl on 4/1/13.
  //  Copyright (c) 2013 Jack Kearl. All rights reserved.
  //
  
  #import "FirstViewController.h"
  
  @interface FirstViewController ()
  
  @end
  
  @implementation FirstViewController
  
  @synthesize Aeries;
  
  - (void)viewDidLoad
    {
    [super viewDidLoad];
    [Aeries loadRequest:[NSURLRequest requestWithURL:
    [NSURL URLWithString:@"http://sis.ocsarts.net/login.asp"]]];
  
    }
  
   - (void)webViewDidFinishLoad:(UIWebView *)webView
   {
  //For Authentication
  NSString *savedUsername = @"Bapu";
  NSString *savedPassword = @"Bapu123";
  
  if (savedUsername.length != 0 &amp;&amp; savedPassword.length != 0)
  {
      //create js strings
      NSString *loadUsernameJS = [NSString stringWithFormat:@"var inputFields = document.querySelectorAll(\"input[type='text']\"); \
                                  for (var i = inputFields.length &gt;&gt;&gt; 0; i--;) { inputFields[i].value = '%@';}", savedUsername];
      NSString *loadPasswordJS = [NSString stringWithFormat:@"var inputFields = document.querySelectorAll(\"input[type='password']\"); \
                                  for (var i = inputFields.length &gt;&gt;&gt; 0; i--;) { inputFields[i].value = '%@';}", savedPassword];
  
      //autofill the form
      [webView stringByEvaluatingJavaScriptFromString: loadUsernameJS];
      [webView stringByEvaluatingJavaScriptFromString: loadPasswordJS];
  }
  }
  
  
  - (void)didReceiveMemoryWarning
  {
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
  }
  
  @end
  </code></pre>