How to - Pass variables to a webform?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
MasterchiefJB
Posts: 76
Joined: Sat Nov 07, 2009 7:43 pm

How to - Pass variables to a webform?

Post by MasterchiefJB » Mon Jul 12, 2010 4:51 pm

Hi again,

this time I want to show a website inside of my application and pass variables to webforms.
Well I managed to show the website inside my application with this code:

Code: Select all

on run_list
   put empty into tBrowserId
   global tBrowserId
   put the windowid of this stack into tWinID 
   put revBrowserOpen(tWinID,"http://www.gmx.net") \ 
          into tBrowserId  
  -- revBrowserNavigate tBrowserId, "http://www.microsoft.com"              
   revBrowserSet tBrowserId, "showborder","true" 
   revBrowserSet tBrowserId, "rect",rect of fld "F_Browser"
   revBrowserRedraw tBrowserId               
end run_list
As I said the website shows up but a strange thing happens if you move your curser above the Browser field: The Side transforms into google.com
First you see the search bar and after some seconds gmx.net or microsoft.com disappears and google.com appears.
I don´t know why this happens as I don´t have declared google.com in any kind in my code! I am really confused about this and I am happy about every kind of help.
I solved the Google.com problem. It was a strange cache error that was solved by reseting the cache of firefox and IE7.
Now I would like to concentrate on the next problem:
The next issue is that I would like to pass data from my input fields to a webform like a login or registration page, but I don´t have a clue how to archieve that.

For example:
My Application has 3 Input Fields (Name, Password, Email) and now I would like to find the corresponding fields on a webpage for Loginname, Password and emailadress.

Best Regards,
Masterchief

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: How to - Pass variables to a webform?

Post by lohill » Sun Jul 18, 2010 7:27 pm

MasterchiefJB,

It looks like we are both in about the same place on this matter. Perhaps the two of us can figure this out but it would be helpful if someone like Andrew would step in and give us some guidance. Take a look at my post on this called 'Question for Andrew':
http://forums.runrev.com/phpBB2/viewtop ... f=8&t=5557

In particular if you go to his website and view the html source of his simple login you will be able to see how he uses
get revBrowserExecuteScript(tBrowserId, "document.form1.user.value = 'demoUser';") to put his value into the web form

In my case, with much more complicated source code for the webform, I am trying (without success yet) to accomplish the 'click' that he so easily does because he has the id of the element.

The following, among others, has not worked for me :
get revBrowserExecuteScript(tBrowserId, "document.getElementsByName('sign_in').click();")

By studying revBrowserExecuteScript in the dictionary I have come up with these that do work and you might get some ideas from them.

get revBrowserExecuteScript(tBrowserId,"alert('This is a message.');") --This one works
put revBrowserExecuteScript(tBrowserId,"result = 1 + 1;") into myVar --This works
put revBrowserExecuteScript(tBrowserId,"result = document.frm_login.username.value;") into myVar --This works

I have tried things like 'revBrowserExecuteScript(tBrowserId,"result = document.getElementsByName();") into myVar. The dictioinary leads me to believe that I should get a list of element names but myVar always seems to be empty.

I think the trick is knowing all about html code and understanding the 'source' code of the web page you are interested in. Unfortunately my background is very weak in this area. I wish I could be more help.

Regards,
Larry

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to - Pass variables to a webform?

Post by Mark » Mon Jul 19, 2010 10:57 am

Dear Larry,

There is a bug in the WebKit that prevents any interection with the browser window. I don't know why, but parsing the result into a string seems to help. You can do this by adding an (empty) string to the result:

Code: Select all

put revBrowserExecuteScript(gBrowserID,"result = document.getElementsByName() + '';") into myElems
Note the two single quotes before the semicolon. This script won't do much but it is a start.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: How to - Pass variables to a webform?

Post by lohill » Tue Jul 20, 2010 12:45 am

Thanks Mark,

Your code did return something to my variable. In the REV debugger myElems shows up as '[object NodeList]'. Is this some special data type? How can I see what is actually in that list?

Regards,
Larry

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How to - Pass variables to a webform?

Post by Mark » Tue Jul 20, 2010 12:50 am

Hi Larry,

Document.getElementsByName() returns an XML tree, but you never see this because it is parsed while you call the correct Javascript functions. You will need to write a Javascript function to retrieve the elements from this XML tree.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

MasterchiefJB
Posts: 76
Joined: Sat Nov 07, 2009 7:43 pm

Re: How to - Pass variables to a webform?

Post by MasterchiefJB » Fri May 06, 2011 10:10 pm

Thanks Larry and Mark!

I just tried to pass variables to a webform using the following structure:

Code: Select all

get revBrowserExecuteScript(tBrowserId, "document.getElementsByName('sign_in').click();")
Works perfect!
I would like to know wheter it would be possible to handle captcha codes with LiveCode?
- I mean: Is it possible to retrieve a Captcha Image from a webform and read it in LiveCode or at least display an Alert Dialog that forces him to insert the Captcha Code himself?
(Basically: How to display a Captcha Code from a website within LiveCode?=

Regards,
Masterchief

Post Reply