Using Webfillform with document.forms[0].elements[0].value
Moderators: Dorian (MJT support), JRL
Using Webfillform with document.forms[0].elements[0].value
How do I use WebFillForm with document.forms[0].elements[0].value
VBRun>WebFormFill,document.forms[0].elements[0].value,In 1st box Pls.
VBRun>WebFormFill,inbox,Put it in the inbox please.
VBRun>WebFormFill,tom2,This is the third box.
Is there a correct way to fill a form that has no names for each box?
The below statement places "hello dolly" in the form just fine, but how can I do it with script without knowing the acual form name or a form or box without a name.
Thanks
Tom
VBRun>WebFormFill,document.forms[0].elements[0].value,In 1st box Pls.
VBRun>WebFormFill,inbox,Put it in the inbox please.
VBRun>WebFormFill,tom2,This is the third box.
Is there a correct way to fill a form that has no names for each box?
The below statement places "hello dolly" in the form just fine, but how can I do it with script without knowing the acual form name or a form or box without a name.
Thanks
Tom
Pretty much in the same way:
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = nothing
End Sub
Sub DoIt
IE.Document.forms(0).elements(0).value="hello dolly"
End Sub
VBEND
VBRun>CreateIE
VBRun>Navigate,http://www.somesite.com
VBRun>DoIt
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = nothing
End Sub
Sub DoIt
IE.Document.forms(0).elements(0).value="hello dolly"
End Sub
VBEND
VBRun>CreateIE
VBRun>Navigate,http://www.somesite.com
VBRun>DoIt
MJT Net Support
[email protected]
[email protected]
Thanks for your quick response, and I assumed once I knew the basic command I could simply apply it. Below is exactly what I am trying to do, but it does not work can you detect my error in coding that causes it not to work?
Thank you for such a super program, I have been using it off and on, but had not purchased yet do to inability to test the compiler without purchase, so this time when I came back I noted the free test of the compiler and will be purchasing the full complier system in the next few days. Thanks again for your quick response.
When you look at my 3 doit's at the bottom, I am sure you can put me on the right track.
I also love the way you can Navigate direct to a hard disk directory as I am doing., without all the double // and tripple //// stuff. Just a common sense path.
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = nothing
End Sub
Sub DoIt(x,y,dat)
IE.Document.forms(x).elements(y).value=dat
End Sub
VBEND
VBRun>CreateIE
VBRun>Navigate,C:\_forms_javascript_analyze\test.htm
VBRun>DoIt,0,0,Fill first form
VBRun>DoIt,0,1,Fill another form
VBRun>DoIt,1,0,Fill yet another form
Thank you for such a super program, I have been using it off and on, but had not purchased yet do to inability to test the compiler without purchase, so this time when I came back I noted the free test of the compiler and will be purchasing the full complier system in the next few days. Thanks again for your quick response.
When you look at my 3 doit's at the bottom, I am sure you can put me on the right track.
I also love the way you can Navigate direct to a hard disk directory as I am doing., without all the double // and tripple //// stuff. Just a common sense path.
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = nothing
End Sub
Sub DoIt(x,y,dat)
IE.Document.forms(x).elements(y).value=dat
End Sub
VBEND
VBRun>CreateIE
VBRun>Navigate,C:\_forms_javascript_analyze\test.htm
VBRun>DoIt,0,0,Fill first form
VBRun>DoIt,0,1,Fill another form
VBRun>DoIt,1,0,Fill yet another form
Hi,
Not sure why but I get an error using a vb subroutine, but it works with a vb function. This works for me:
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = nothing
End Sub
Function DoIt(x,y,dat)
IE.Document.forms(x).elements(y).value=dat
End Function
VBEND
VBRun>CreateIE
VBRun>Navigate,f:\html\test.htm
VBEval>DoIt(0,0,"hello"),nul
VBEval>DoIt(0,1,"world"),nul
This populates the first two elements of the first form on the page. Bear in mind that form elements can be hidden and this way of calling the function cares not about that or what their names are or what type of element they are - it simply populates an element by it's index. If the first two elements in the form were hidden the above would appear to the use to do nothing, but would be setting them. This is my test.htm page:
Just two input fields.
If you know the name of the fields you can pass the element name instead of it's index:
VBEval>DoIt(0,"field1","hello"),nul
VBEval>DoIt(0,"field2","world"),nul
If you send a string it uses the name, an integer, it's index. That will work for the form too. So if you know the name of the form:
VBEval>DoIt("myform","field1","hello"),nul
VBEval>DoIt("myform","field2","world"),nul
Isn't Internet Explorer's Document Object Model awesome!!?
This is just scratching at the surface!
Not sure why but I get an error using a vb subroutine, but it works with a vb function. This works for me:
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = nothing
End Sub
Function DoIt(x,y,dat)
IE.Document.forms(x).elements(y).value=dat
End Function
VBEND
VBRun>CreateIE
VBRun>Navigate,f:\html\test.htm
VBEval>DoIt(0,0,"hello"),nul
VBEval>DoIt(0,1,"world"),nul
This populates the first two elements of the first form on the page. Bear in mind that form elements can be hidden and this way of calling the function cares not about that or what their names are or what type of element they are - it simply populates an element by it's index. If the first two elements in the form were hidden the above would appear to the use to do nothing, but would be setting them. This is my test.htm page:
Just two input fields.
If you know the name of the fields you can pass the element name instead of it's index:
VBEval>DoIt(0,"field1","hello"),nul
VBEval>DoIt(0,"field2","world"),nul
If you send a string it uses the name, an integer, it's index. That will work for the form too. So if you know the name of the form:
VBEval>DoIt("myform","field1","hello"),nul
VBEval>DoIt("myform","field2","world"),nul
Isn't Internet Explorer's Document Object Model awesome!!?
This is just scratching at the surface!
MJT Net Support
[email protected]
[email protected]
Thank you! Thank you! Thank you! That worked fantastic. I was having the same problem as you, it would not work on a subroutine so I am glad you switched to a function. I would have never thought of that. Hey, it would be nice to be able to use this either as a function or sub. However the function will work just fine for me. Maybe you could ear mark this one to see what is causing the error before the next issue of the program. I love this program, so expect to see a compiler order in the next few days.
I tested this thing thoroughly as you can see below. Works fantastic
Thanks again. Hopefully a few others are following along with our discussion and they will also learn some new things.
Also I would never have thought to add the nul on the end.
VBRun>CreateIE
VBRun>Navigate,C:\_forms_javascript_analyze\test.htm
VBEval>DoIt(0,0,"Box 1-1"),nul
VBEval>DoIt(0,1,"Box 2-1"),nul
VBEval>DoIt(0,2,"Box 3-1"),nul
VBEval>DoIt(1,0,"Box 1-2"),nul
VBEval>DoIt(1,1,"Box 2-2"),nul
VBEval>DoIt(1,2,"Box 3-2"),nul
VBEval>DoIt(2,0,"Box 1-3"),nul
VBEval>DoIt(2,1,"Box 2-3"),nul
VBEval>DoIt(2,2,"Box 3-3"),nul
I tested this thing thoroughly as you can see below. Works fantastic
Thanks again. Hopefully a few others are following along with our discussion and they will also learn some new things.
Also I would never have thought to add the nul on the end.
VBRun>CreateIE
VBRun>Navigate,C:\_forms_javascript_analyze\test.htm
VBEval>DoIt(0,0,"Box 1-1"),nul
VBEval>DoIt(0,1,"Box 2-1"),nul
VBEval>DoIt(0,2,"Box 3-1"),nul
VBEval>DoIt(1,0,"Box 1-2"),nul
VBEval>DoIt(1,1,"Box 2-2"),nul
VBEval>DoIt(1,2,"Box 3-2"),nul
VBEval>DoIt(2,0,"Box 1-3"),nul
VBEval>DoIt(2,1,"Box 2-3"),nul
VBEval>DoIt(2,2,"Box 3-3"),nul
Seems to be something to do with the IE interface not liking the values being transformed from MacroScript to VBScript in VBRun. VBEval is safer anyway because it evaluates straight VBScript code. But we'll look into it and see if there is anything obvious going on here.
I added nul because VBEval expects a return variable.
Another, easier, way of creating macros to automate IE is to use WebRecorder: http://www.mjtnet.com/webrecorder.htm
I added nul because VBEval expects a return variable.
Another, easier, way of creating macros to automate IE is to use WebRecorder: http://www.mjtnet.com/webrecorder.htm
MJT Net Support
[email protected]
[email protected]
Doesn't webrecorder restrict you to making sure the display is always the same size and etc. With the method I am using, I can shrink the ie screen down to the size of your thumb nail and it still works.
The web recorders I used in the past had been notorious for requiring the screen set the same al the time.
Does your webcorder get around this?
In other words don't it require so many pixels over and so many down.
The web recorders I used in the past had been notorious for requiring the screen set the same al the time.
Does your webcorder get around this?
In other words don't it require so many pixels over and so many down.
No, WebRecorder does NO GUI work at all. It uses IE's document object model (DOM) but works at an even lower level than VBScript can and is therefore capable of more. With VBScript you will at some point run into site scripting security restrictions which prevent scripts from automating certain objects. WebRecorder uses the IE DOM interface at a lower level that circumvents this.
MJT Net Support
[email protected]
[email protected]
Tom Chambers said:
Thank you! Thank you! Thank you! That worked fantastic. (referring to the macro fix above). I was having the same problem as you, it would not work on a subroutine so I am glad you switched to a function. I would have never thought of that. Thanks again for the immediate response.
Tom Chambers said again:
Thank you for the heads up, this has to be the best Macro Recorder since they invented "snuff". For you young folks, that is a tobacco that is chewed. I have used a lot of far more expensive recorders and they just don't hold a candle.
This is definitely not a paid commercial anouncement, and please feel free to use my words in any advertising you would like. Hell I would even be willing to give you an email that you can use with the ad. Don't use my email on file, as if it gets bombarded with inquiries, I might have to back out, but i certainly would respond to a few dozen inquiries. I love you, but not enough to give up my day job just to answer inquires.
Bottom line you have a sold customer for life.
Thank you! Thank you! Thank you! That worked fantastic. (referring to the macro fix above). I was having the same problem as you, it would not work on a subroutine so I am glad you switched to a function. I would have never thought of that. Thanks again for the immediate response.
Tom Chambers said again:
Thank you for the heads up, this has to be the best Macro Recorder since they invented "snuff". For you young folks, that is a tobacco that is chewed. I have used a lot of far more expensive recorders and they just don't hold a candle.
This is definitely not a paid commercial anouncement, and please feel free to use my words in any advertising you would like. Hell I would even be willing to give you an email that you can use with the ad. Don't use my email on file, as if it gets bombarded with inquiries, I might have to back out, but i certainly would respond to a few dozen inquiries. I love you, but not enough to give up my day job just to answer inquires.
Bottom line you have a sold customer for life.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Wow thanks for the wonderful comments! They will get pride of place on our new website
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Newbie
- Posts: 8
- Joined: Sun Apr 09, 2006 10:40 pm
How do i do this with the radio button
Hello,
I'have followd your example to fill some text,
My third element is a radio button and i have to tried select it
with value of "true"
but it doesnt work
whats wrong?
I'have followd your example to fill some text,
My third element is a radio button and i have to tried select it
with value of "true"
but it doesnt work
whats wrong?
I would suggest the reason for the problem with the subroutines: when you call VBEval, then you can transfer all variables the way you want them to be transferred: you are in charge of if the numbers are passed as numbers or as strings. When you call VBRun, the numbers are passed as strings, you have to call CLng in VBScript to transform them to numbers.support wrote:Seems to be something to do with the IE interface not liking the values being transformed from MacroScript to VBScript in VBRun. VBEval is safer anyway because it evaluates straight VBScript code. But we'll look into it and see if there is anything obvious going on here.
I added nul because VBEval expects a return variable.
Another, easier, way of creating macros to automate IE is to use WebRecorder: http://www.mjtnet.com/webrecorder
So possibly, IE expects to see numbers as function parameters.
Olga.
P.S. I certainly agree, MS is a great program! :)
Re: How do i do this with the radio button
Possibly the same problem: if you're calling it passing "true" as string, IE might not like it.nachtegaal9999 wrote:Hello,
I'have followd your example to fill some text,
My third element is a radio button and i have to tried select it
with value of "true"
but it doesnt work
whats wrong?