Dynamically create/pass form info via XMLHttp

Here is a quick little sample for dynamically creating a form and posting it to a page using the XMLHttp object.

Here is a quick little sample for dynamically creating
a form and posting it to a page using the XMLHttp object.
This can be helpful if you need to automatically format information via an HTML form and post it to normal HTML pages instead of keying in the information manually.


Function SendDynamicForm(sVal1,sVal2)

Dim oXMLHttp
Dim sForm

on error resume next

sForm="id=" & sVal1 & "&cust=" & sVal2

Set oXMLHttp=Server.CreateObject("MSXML2.XMLHTTP")

oXMLHttp.open "POST", "http://www.mysite.com/mypage.asp", false
oXMLHttp.setRequestHeader "lastCached", now()
oXMLHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXMLHttp.send sForm

if oXMLHttp.status = 200 Then
SendDynamicForm = oXMLHttp.responseText
end if

Set oXMLHttp = Nothing

End Function


Submission Date:  9/23/2005 3:01:20 PM
Submitted By:  Robbe Morris
My Home Page:  http://www.robbemorris.com

By Robbe Morris   Popularity  (775 Views)
Picture
Biography - Robbe Morris
Robbe has been a Microsoft MVP in C# since 2004. He is also the co-founder of NullSkull.com which provides .NET articles, book reviews, software reviews, and software download and purchase advice.  Robbe also loves to scuba dive and go deep sea fishing in the Florida Keys or off the coast of Daytona Beach. Microsoft MVP
Here's my most recent course on Pluralsight. I think it has some interesting insight on IT professional job interviews and using words in your resume to influence the questions you'll be asked. Resumes, Job Seeking, and Interviews in context.