Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:32:23+00:00 2026-05-30T03:32:23+00:00

I want to fill in a text box inside a UIWebView, so I am

  • 0

I want to fill in a text box inside a UIWebView, so I am using the following code to do so;

NSString *inputipjavascript = [NSString stringWithFormat:@"document.getElementById('IP').value = '%@';", enterip];

NSString *result;
[webView stringByEvaluatingJavaScriptFromString:inputipjavascript];
result = [webView stringByEvaluatingJavaScriptFromString:@"$('#GD').click();"];

The page which has the form on which I want to fill out automatically and submit is:

http://www.whatismyip.com/tools/ip-address-lookup.asp

The above code doesn’t work at all, what do I need to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:32:24+00:00Added an answer on May 30, 2026 at 3:32 am

    The most likely explanation based on the limited details of the context of your code, is that you are ignoring the asynchronous nature of the loadRequest: method and trying to execute your javascript commands before the DOM has loaded. Thus executing your commands on nothing. The UIWebView way to handle this is to use the -(void)webViewDidFinishLoad:(UIWebView *)webView; delegate method.

    Edit: To “I did this already, but it didn’t work.”.

    After examining the page at your link:http://www.whatismyip.com/tools/ip-address-lookup.asp. Your javascript is not compatible with the elements of your target webpage. For example here is the tag of the IP input field.

    <input type="text" name="IP" value="xxx.xxx.xxx.xxx">

    And you are trying to use getElementById('IP') to get access to it. It has no id element so you are not referencing anything. The most precise specifier is the name element, it’s value being IP. The first method that came to mind was getElementsByName(), then I just have to use element [0].

    For a quick test I threw a few lines in an IBAction for a test and they worked for me:

    - (IBAction)enterAndPress:(id)sender {
        NSString *enterip = @"74.125.227.50"; // take that google
        [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementsByName('IP')[0].value = '%@';",enterip]];
        [self.webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('GL')[0].click();"];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using C# and ASP.NET I want to programmatically fill in some values (4 text
<label id=error_msg></label> Now, I want to alert a message that please fill text-box, whenever
I am using JSON for first time... and want to fill my datagrid with
I have a for loop. Inside that loop I want to fill up an
I want to create a very simple search partial. It has a text box,
The following is my code. I want an interface where I have a single
I want to wire a text box to a BindingSource . I tried this:
I want to keep the data inputted in a text box in my form
Very simply I want to fill in the message box that is generated by
I am trying to display a text box using textView.I am adding some data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.