Spidersaw
Spidersaw

Reputation: 354

Getting String from a textfield inside webpage iOS

I'd like to get the content in a textfield (with an assigned ID) on a webpage and pass it into a NSString. Is there a way to load it instantly without taking every html source? Thanks in advance. P.S. I use objective-c

Upvotes: 0

Views: 56

Answers (1)

Wayne Hartman
Wayne Hartman

Reputation: 18487

You can execute javascript using the stringByEvaluatingJavaScriptFromString: method on UIWebView in order to get the value of the textfield. For example, if its ID is foo, you can write:

NSString *js = @"document.getElementById('foo').value";
NSString *value = [webview stringByEvaluatingJavaScriptFromString:js];

Upvotes: 1

Related Questions