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 7430279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:06:51+00:00 2026-05-29T09:06:51+00:00

i have an example of a source code which programatically sets the value of

  • 0

i have an example of a source code which programatically sets the value of fields in an HTML.

The part of the source code is as such:

- (void)viewDidLoad
{
[super viewDidLoad];

myWebView.delegate = self;

//---formulate the HTML string---
NSString *str = [[[NSString alloc] initWithString:
                @"<html>"
                 "    <body>"
                 "        <h1>The fields below are filled in programmatically</h1>"
                 "        <input id='username' value='UserName' />"
                 "        <input id='password' value='Password' type='password' />"
                 "    </body>"
                 "</html>"
                 ] autorelease];

//---load the UIWebView with the html string---
[myWebView loadHTMLString:str baseURL:nil];
}

//---wait for the UIWebView to finish loading---
- (void)webViewDidFinishLoad:(UIWebView *)webView {
//---access the 2 fields in the HTML---
[myWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('username').value='Wei-Meng Lee';"];
[myWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('password').value='TopSecret';"];
}

I would like to programmatically set value of fields in an actually webpage like Facebook instead of a custom HTML like such written above.

How should i replace the “str” to an actual webpage’s html source code so that i can pick out the “ElementbyId”?

  • 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-29T09:06:51+00:00Added an answer on May 29, 2026 at 9:06 am

    by replacing

    //---formulate the HTML string---
    NSString *str = [[[NSString alloc] initWithString:
                @"<html>"
                 "    <body>"
                 "        <h1>The fields below are filled in programmatically</h1>"
                 "        <input id='username' value='UserName' />"
                 "        <input id='password' value='Password' type='password' />"
                 "    </body>"
                 "</html>"
                 ] autorelease];
    
    //---load the UIWebView with the html string---
    [myWebView loadHTMLString:str baseURL:nil];
    

    with [UIWebView loadRequest] and it will load the web view with the URL and the UIWebView will contain the HTML to make stringByEvaluatingJavaScriptFromString work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example: I'm on MS DOS, I have a source code in the folder
I have some source code file which has mixed tabs/spaces and I want to
I'm looking for a good source code example of a supervised neural network which
I have a properties file in which the keys represent strings in source code
I have svn repository with source code which I want to link (right click
I have seen simple example Ajax source codes in many online tutorials. What I
I have a model: class Example(models.Model): unique_hash = models.CharField(max_length=32,unique=True) content = models.FileField(upload_to='source',blank=True,verbose_name=HTML Content File)
Most of our Eclipse projects have multiple source folders, for example: src/main/java src/test/java When
Ok, so I have a given video source (for the sake of the example,
I have example of code below. <script type=text/javascript src=assets/scripts/somescript.php>. </script> So, will my browser

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.