Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Submitting a <form> using VB or VBScript

190 views
Skip to first unread message

Shaba

unread,
Sep 26, 2001, 7:09:24 PM9/26/01
to
Hello all,

I was just wondering how and if its possible
to submit a <form> programatically using VB
or a "stand-alone" VBScript.

Is there any way to create a "document"
object outside a web browser (HTML Document)?
Something like ...

Set form = CreateObject("Document.Form")
form.username.Value = "username"
form.password.Value = "password"
form.Method = "POST"
form.Action = "http://www.name.com/login"
form.Submit

Thanks in advance!
/Shaba

Michael Harris (MVP)

unread,
Sep 26, 2001, 7:43:40 PM9/26/01
to
Here's a working VBScript example (easily ported to VB)...

set http = createobject("msxml2.xmlhttp")
'
' pre-XML 3.0, use "msxml.xmlhttp" as the progid...
'
' if server side use:
'
'==> set http = createobject("msxml2.serverxmlhttp")
'
' which requires XML 3.0 or higher...
'
url = "http://localhost/test/enumform.asp"
foo = "this is foo"
bar = "this/is/bar"
sFormData = _
"foo=" & escape(foo) _
& "&bar=" & escape(bar)
http.open "POST",url,false
http.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
http.send sFormData
msgbox http.responseText

====enumform.asp====
<%
set f = request.form
for each v in f
response.write v & "=" & f.item(v) & "<br>" & vbcrlf
next
%>


--

Michael Harris
Microsoft.MVP.Scripting
--
mik...@mvps.org
Please do not email questions - post them to the newsgroup instead.
--
"Shaba" <shahryar_...@hotmail.com> wrote in message
news:138e01c146e0$484d5210$b1e62ecf@tkmsftngxa04...

0 new messages