Browser Widget LC button to fill and submit form
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Browser Widget LC button to fill and submit form
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
Any help appreciated
Allan
Re: Browser Widget LC button to fill and submit form
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).
p.s. Questions to widgets, especially the browser widget, are better visible in the LCB forum (LiveCode Builder).
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
shiftLock happens
Re: Browser Widget LC button to fill and submit form
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
This thread is old but still workable and may give some ideas viewtopic.php?f=7&t=16602&p=87985
-
- Posts: 723
- Joined: Thu Sep 11, 2014 1:49 pm
Re: Browser Widget LC button to fill and submit form
Maybe this java browser integration tutorial can help ?
Livecode Javascript communication
https://www.youtube.com/watch?v=xI_4PS_18uM&t=19s
regards,
Paul
Livecode Javascript communication
https://www.youtube.com/watch?v=xI_4PS_18uM&t=19s
regards,
Paul
Re: Browser Widget LC button to fill and submit form
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.
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
Re: Browser Widget LC button to fill and submit form
Thanks everyone. Used the Javascript approach and now submitting forms successfully.
Cheers
Allan
Cheers
Allan
-
- Posts: 652
- Joined: Tue Jul 29, 2014 12:52 am
Re: Browser Widget LC button to fill and submit form
Hi all, I's like to use the Javascript approach to submit a form to upload a file to a web server. I'm confussed about to what exactly 'myTextarea' is referring to in the piece of code provided by Hermann
Just to make myself more clear the page I want to "cheat" looks like this
and I'd like my LC script to fill in the file name (which I already know) and "press" the Submit button.
I'd really appreciate any help with it.
Many thanks in advance
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
and I'd like my LC script to fill in the file name (which I already know) and "press" the Submit button.
I'd really appreciate any help with it.
Many thanks in advance
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question