Connecting Tech Pros Worldwide Forums | Help | Site Map

One last WebBrowser DOM question...

Noozer
Guest
 
Posts: n/a
#1: Jul 17 '05
One last question and I will have my application working the way that I
need...

How can you put a value into a specific field on a specific form?

If you look at the webpage sample below you will see that there are three
forms on the page. Each form has a unique name, but the input tags are
duplicated on each form.

How would I (for example) assign the value "Bob" to the input box named
"username" on the form named "FormTwo" in VB6 using the WebBrowser DOM???

<html>
<head>
</head>
<body>
<form name="FormOne" action = "">
Name: <input type="text" name ="username"> <br>
Password: <input type="password" name="password"><br>
<input type="submit" name="submit">
</form>
<hr>
<form name="FormTwo" action = "">
Name: <input type="text" name ="username"> <br>
Password: <input type="password" name="password"><br>
<input type="submit" name="submit">
</form>
<hr>
<form name="FormThree" action = "">
Form3<br>
Name: <input type="text" name ="username"> <br>
Password: <input type="password" name="password"><br>
<input type="submit" name="submit">
</form>
</body>
</html>



mayayana
Guest
 
Posts: n/a
#2: Jul 17 '05

re: One last WebBrowser DOM question...


There may be an easier way than this but offhand:
You can always get anything with "all". From the
all element collection, in a loop, you can look for
elements with tagName = "INPUT", then find the
one with the right name property. They also have
a "type" property. (Text, Password, etc.)


[color=blue]
> One last question and I will have my application working the way that I
> need...
>
> How can you put a value into a specific field on a specific form?
>
> If you look at the webpage sample below you will see that there are three
> forms on the page. Each form has a unique name, but the input tags are
> duplicated on each form.
>
> How would I (for example) assign the value "Bob" to the input box named
> "username" on the form named "FormTwo" in VB6 using the WebBrowser DOM???
>
> <html>
> <head>
> </head>
> <body>
> <form name="FormOne" action = "">
> Name: <input type="text" name ="username"> <br>
> Password: <input type="password" name="password"><br>
> <input type="submit" name="submit">
> </form>
> <hr>
> <form name="FormTwo" action = "">
> Name: <input type="text" name ="username"> <br>
> Password: <input type="password" name="password"><br>
> <input type="submit" name="submit">
> </form>
> <hr>
> <form name="FormThree" action = "">
> Form3<br>
> Name: <input type="text" name ="username"> <br>
> Password: <input type="password" name="password"><br>
> <input type="submit" name="submit">
> </form>
> </body>
> </html>
>
>[/color]


nate
Guest
 
Posts: n/a
#3: Jul 17 '05

re: One last WebBrowser DOM question...



Noozer,

I once spent hours trying to figure this out. Someone on this newsgroup
told me how to do it with one line of code:

webBrowser.Document.Forms("FormOne")("username").V alue = "bob"

nate


"Noozer" <dont.spam@me.here> wrote in message
news:jGirc.552581$oR5.183772@pd7tw3no...[color=blue]
> One last question and I will have my application working the way that I
> need...
>
> How can you put a value into a specific field on a specific form?
>
> If you look at the webpage sample below you will see that there are three
> forms on the page. Each form has a unique name, but the input tags are
> duplicated on each form.
>
> How would I (for example) assign the value "Bob" to the input box named
> "username" on the form named "FormTwo" in VB6 using the WebBrowser DOM???
>
> <html>
> <head>
> </head>
> <body>
> <form name="FormOne" action = "">
> Name: <input type="text" name ="username"> <br>
> Password: <input type="password" name="password"><br>
> <input type="submit" name="submit">
> </form>
> <hr>
> <form name="FormTwo" action = "">
> Name: <input type="text" name ="username"> <br>
> Password: <input type="password" name="password"><br>
> <input type="submit" name="submit">
> </form>
> <hr>
> <form name="FormThree" action = "">
> Form3<br>
> Name: <input type="text" name ="username"> <br>
> Password: <input type="password" name="password"><br>
> <input type="submit" name="submit">
> </form>
> </body>
> </html>
>
>[/color]


Grahammer
Guest
 
Posts: n/a
#4: Jul 17 '05

re: One last WebBrowser DOM question...


Thank you VERY much!

I knew there had to be a simple way... this makes perfect sense now that I
see it.

"nate" <nate@hello.com> wrote in message
news:HZurc.1156$2H2.682@fe2.columbus.rr.com...[color=blue]
>
> Noozer,
>
> I once spent hours trying to figure this out. Someone on this newsgroup
> told me how to do it with one line of code:
>
> webBrowser.Document.Forms("FormOne")("username").V alue = "bob"[/color]
[color=blue][color=green]
> > How can you put a value into a specific field on a specific form?[/color][/color]


Closed Thread


Similar Visual Basic 4 / 5 / 6 bytes