You can call a javascript method and pass the value by using this
NSString *selectedValue = [webViewInstance stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"getAndReturnRadioValue(%d)", questionCounterIntValue]];
But to trigger back from javascript you need to use a workaround method,
Implement the following webViewDelegate method
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSLog(@"passed data from web view : %@",[[request URL] query]);
if([[[request URL] query] isEqualToString:@"clickedOnLineNo"])
{
//Do your action here
}
}
You have to navigate to a fake URL from your javascript method like,
window.location = "someLink://yourApp/form_Submitted:param1:param2:param3";
on a button click or your required action.
You could take a look at my answer for this question
Submit a form in UIWebView
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…