By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,218 Members | 1,111 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,218 IT Pros & Developers. It's quick & easy.

Using Microsoft.XMLHTTP causes all GET values to revert to "0"

P: n/a
[ASP]
'GET THE HTML CONTENT FOR DISPLAY BAND ORIGIN
Dim bandOriginDropdown
On Error Resume Next
set scraper = Server.CreateObject("Microsoft.XMLHTTP")
if err then
bandOriginDropdown = ""
else
scraper.open "GET", path &
"/includes/soa_form_element_plugin.inc.asp", false
scraper.send "tableID=2&fieldID=1&typeID=0"
bandOriginDropdown = scraper.ResponseText
set scraper = nothing
end if
[/ASP]

This is a code snippet based upon a scrape on an included ASP script I
wrote that is designed to produce dynamically generated HTML form
element material based upon query string values that are read into
globally-included arrays:

[ASP]
Dim tableNameArray(2)
tableNameArray(0) = "event"
tableNameArray(1) = "gb"
tableNameArray(2) = "bands"

Dim fieldArray(4,2)
fieldArray(0,0) = "event_name"
fieldArray(0,1) = "event_date"
fieldArray(0,2) = "event_text"
fieldArray(1,0) = "last_name"
fieldArray(1,1) = "url"
fieldArray(1,2) = "fave_bands"
fieldArray(2,0) = "bandStyle"
fieldArray(2,1) = "bandOrigin"
fieldArray(2,2) = "bandDescription"

Dim formElementTypeArray(3)
formElementTypeArray(0) = "dropdown"
formElementTypeArray(1) = "text"
formElementTypeArray(2) = "textarea"
formElementTypeArray(3) = "hidden"
[/ASP]

Here is the ASP script soa_form_element_plugin.inc.asp:

[ASP]
<!--#include virtual=/soa/includes/val_global_vars_functions.asp -->
<%
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''
' file: soa_form_element_plugin.inc.asp
'
' created by: Phil Powell on 7/24/2005 '
' '
' Produce a dropdown list of band-related items whereby the '
' Request.QueryString collection object determines which field '
' you will obtain and data to produce into an HTML form '
' element type dictated by global variables tableNameArray and '
' fieldArray '
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''

Dim myField, formElementType
if IsNumeric(Request.QueryString("tableID")) then tableName =
tableNameArray(Request.QueryString("tableID"))
if IsNumeric(Request.QueryString("tableID")) and
IsNumeric(Request.QueryString("fieldID")) then
myField = fieldArray(Request.QueryString("tableID"),
Request.QueryString("fieldID"))
end if
if IsNumeric(Request.QueryString("typeID")) then myElementType =
formElementTypeArray(Request.QueryString("typeID") )

Response.Write("tableID = " & Request.QueryString("tableID"))

if not IsNull(myField) and myField <> "" and not IsNull(tableName)
and tableName <> "" then
Dim Conn, rs
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath("\soa\db\sub.mdb")

sql = "SELECT DISTINCT " & myField & " " &_
"FROM " & tableName & " " &_
"WHERE " & myField & " IS NOT NULL" &_
" AND " & myField & " <> '' " &_
"ORDER BY " & myField & " ASC"

set rs = Conn.execute(sql)
if strcomp(lcase(myElementType), "text") = 0 then
%>
<input name="my_<%= myField %>" size="50" maxlength="255" value="<%=
Replace(Request.Form("my_" & myField), """", "&quot;") %>">
<%
elseif strcomp(lcase(myElementType), "textarea") = 0 then
%>
<textarea name="my_<%= myField %>" rows="8" cols="40"><%=
Replace(Request.Form("my_" & myField), "<", "&lt;") %></textarea>
<%
elseif strcomp(lcase(myElementType), "hidden") = 0 then
%>
<input type="hidden" name="my_<%= myField %>" value="<%=
Replace(Request.Form("my_" & myField), """", "&quot;") %>">
<%
elseif strcomp(lcase(myElementType), "dropdown") = 0 then
%>

<select name="my_<%= myField %>">
<option value="">Choose From Below:</option>
<option value="">------------------</option>

<%
do until rs.eof
%>

<option value="<%= rs("" & myField & "") %>"<%

if strcomp(Request.Form("my_" & myField), rs("" & myField & "")) =
0 then Response.Write(" selected")

%>><%= rs("" & myField & "") %></option>

<%
rs.moveNext
loop
set rs = nothing
%>

</select>

<%
end if ' END OF FORM ELEMENT TYPE SELECTION

end if ' END OF DISPLAY

Conn.Close
set Conn = nothing
%>
[/ASP]

Sorry so much code, but there is no way I can think of to explain my
problem.

Here is the output of the Response.Write:

tableID =
However, if I call the URL directly

http://www3.brinkster.com/soa/includ...dID=1&typeID=0

This is what I get:

tableID = 2
Could someone help me with this one? It's live and broken and I can't
fix it (up until 4:30am on this and have had no luck fixing it)

Thanx
Phil

Jul 25 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


Phil Powell wrote:
[ASP]
'GET THE HTML CONTENT FOR DISPLAY BAND ORIGIN
Dim bandOriginDropdown
On Error Resume Next
set scraper = Server.CreateObject("Microsoft.XMLHTTP")
if err then
bandOriginDropdown = ""
else
scraper.open "GET", path &
"/includes/soa_form_element_plugin.inc.asp", false
scraper.send "tableID=2&fieldID=1&typeID=0"


A HTTP GET request does not have a request body so it makes no sense to
pass anything to the send method if you do open "GET".
If you want to pass values with a GET request then the only way is to
use the query string part of the URL e.g.
scraper.open "GET", path &
"/includes/soa_form_element_plugin.inc.asp" &
"?tableID=2&fieldID=1&typeID=0"
Then soa_form_element_plugin.inc.asp can read out
Request.QueryString("tableID")
for instance.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 25 '05 #2

P: n/a
Thanx that's what I wound up trying last night for it to work. Please
explain why HTTP GET request does not have a request body yet HTTP POST
apparently does. They are both HTTP-based collection objects, so they
should both have a request body, just in different formats, one via the
URL and the other via an HTTP POST method.

Phil

Jul 25 '05 #3

P: n/a


Phil Powell wrote:
Please
explain why HTTP GET request does not have a request body yet HTTP POST
apparently does. They are both HTTP-based collection objects, so they
should both have a request body, just in different formats, one via the
URL and the other via an HTTP POST method.


Look into the HTTP specification, a HTTP GET request does not have a
request body, it consists solely of the request line and the request
headers.
POST or PUT requests have a request body.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jul 25 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.