Call 'action' on HTML web form in a UIWebView
<p>I'm trying to skip the login page of a website, so I can give the user a more aesthetically appealing login page, and save their login credentials for automatic login in the future. So far I have two UITextFields, and a UIButton. The user enters their username and password, and upon pressing the UIButton their details are entered into the actual webform on the sites login page, and the subsequent 'logged-in' page is shown in a UIWebView. The webView will be hidden while the app logs the user in, and then presented when the 'logged-in' page has loaded.</p>

<p>I've managed to populate the webform, but simply can't actually submit it! I'm sure there's a very simple solution!</p>

<p>This is the code I have so far, and if there's a better way I should be doing this let me know!</p>

<pre><code>-(IBAction)login:(id)sender
{   
    // Create js strings    
    NSString *loadUsernameJS = [NSString stringWithFormat:@"var username = document.getElementsByName('username')[0]; username.value='%@';", username.text];
    NSString *loadPasswordJS = [NSString stringWithFormat:@"var password = document.getElementsByName('password')[0]; password.value='%@';", password.text];    

    // Autofill the form - this works, and I can see the values being put into the webform
    [self.webView stringByEvaluatingJavaScriptFromString: loadUsernameJS];
    [self.webView stringByEvaluatingJavaScriptFromString: loadPasswordJS];

        // This is the method I have tried to submit the form, but nothing happens (ct100 is the ID of the form).

    [self.webView stringByEvaluatingJavaScriptFromString:@"document.ct100.submit();"];

}
</code></pre>
