Browser Widget LC button to fill and submit form

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
adxsoft
Posts: 25
Joined: Wed Apr 11, 2018 12:25 pm

Browser Widget LC button to fill and submit form

Post by adxsoft » Thu Sep 05, 2019 8:06 am

Using the Browser Widget in LC8/9, I have retrieved an html page from my web server that has several input fields in an html form and am trying to figure out how to write some LC code that can fill in the input fields and submit the web page. In this way I can achieve my objective to use LC to sign into my web server, perform some queries and return my stats data back to a LC field or grid.

Any help appreciated

Allan

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Browser Widget LC button to fill and submit form

Post by [-hh] » Sat Sep 07, 2019 8:59 pm

You can do all that from LC with JavaScript (no other way).
Simply use do <string> in widget "Browser".
Important: The <string> has to be ONE line, use ";" between JS commands.

For example (the field containes no quotes, use single quotes as \' instead or work around).

Code: Select all

on mouseUp
  put fld "Textarea" into str
  replace cr with "\n" in str
  do "document.getElementById('myTextarea')." & \
     "value='" &str& "';" in widget "Browser"
end mouseUp
p.s. Questions to widgets, especially the browser widget, are better visible in the LCB forum (LiveCode Builder).
shiftLock happens

SparkOut
Posts: 2288
Joined: Sun Sep 23, 2007 4:58 pm

Re: Browser Widget LC button to fill and submit form

Post by SparkOut » Sat Sep 07, 2019 10:28 pm

Well you can't go wrong with help from Hermann, but if your objective is to log in and download data to view in LiveCode rather than interacting with a browser widget, you might find it possible to do this directly in LiveCode script (as opposed to LCB and/or javascript to leverage browser widget functionality)
This thread is old but still workable and may give some ideas viewtopic.php?f=7&t=16602&p=87985

mrcoollion
Posts: 572
Joined: Thu Sep 11, 2014 1:49 pm
Location: The Netherlands

Re: Browser Widget LC button to fill and submit form

Post by mrcoollion » Sun Sep 08, 2019 11:42 am

Maybe this java browser integration tutorial can help ?
Livecode Javascript communication
https://www.youtube.com/watch?v=xI_4PS_18uM&t=19s

regards,

Paul

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Browser Widget LC button to fill and submit form

Post by [-hh] » Tue Sep 10, 2019 11:34 am

The method described in the tutorial uses the revBowser external. This is available since LC 6.7.
So nothing new, but some thing is old:

The newer HTML5 (canvas) methods, say past 2010, are supported by revBrowser ONLY on Mac, NOT on Windows.

So be aware of that when using newer HTML5 methods/libraries with that external.
But using javascript in a browser widget works on Mac, Win and all Ubuntu flavours.
shiftLock happens

adxsoft
Posts: 25
Joined: Wed Apr 11, 2018 12:25 pm

Re: Browser Widget LC button to fill and submit form

Post by adxsoft » Sat Apr 11, 2020 3:08 am

Thanks everyone. Used the Javascript approach and now submitting forms successfully.
Cheers
Allan

Post Reply

Return to “Internet”