• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Programmatic web form fill-in?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programmatic web form fill-in?


  • Subject: Re: Programmatic web form fill-in?
  • From: Bob Estes <email@hidden>
  • Date: Thu, 6 Apr 2006 13:24:14 -0400

Thanks, John. That appears to be just what I need.

On Apr 6, 2006, at 10:48 AM, John Pannell wrote:

Hi Bob-

I just did something similar using the DOM via Cocoa. Here's a snippet that fills out form elements and submits the form... inputKeys is an array of keys for the desired form elements, and inputValues is an array of corresponding values for the keys...

// search form for same key value pairs and set values
DOMDocument *document = [frame DOMDocument];
DOMNodeList *formNodeList = [document getElementsByTagName:@"FORM"];
int i;


for(i=0; i < [formNodeList length]; i++){
BOOL authForm = NO;
DOMHTMLFormElement *formNode = (DOMHTMLFormElement *) [formNodeList item:i];
// get inputs from form
DOMNodeList *inputNodeList = [formNode getElementsByTagName:@"INPUT"];
int j;


for(j = 0; j < [inputNodeList length]; j++){
DOMHTMLInputElement *inputNode = (DOMHTMLInputElement *)[inputNodeList item:j];
if([inputKeys containsObject:[inputNode name]]){
[inputNode setValue:[inputValues objectAtIndex: [inputKeys indexOfObject:[inputNode name]]] forKey:@"value"];
authForm = YES;
}
}


            if(authForm){
                // submit this form
                [formNode submit];
            }
        }

Hope this helps!

John

On Apr 6, 2006, at 8:36 AM, Bob Estes wrote:

I would like to be able to fill in an online html form from within a cocoa program. I assume a webview will enable me to display the form within my program, but how can I fill it in with my already chosen text/string with a click of a (cocoa) button?

Thanks,
Bob Estes

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Programmatic web form fill-in? (From: Bob Estes <email@hidden>)
 >Re: Programmatic web form fill-in? (From: John Pannell <email@hidden>)

  • Prev by Date: Re: How to add items to a Pop-up menu
  • Next by Date: 'valueForUndefinedKey' when the 'key' accessor already exists (part deux)
  • Previous by thread: Re: Programmatic web form fill-in?
  • Next by thread: Re: Programmatic web form fill-in?
  • Index(es):
    • Date
    • Thread