'GET THE HTML CONTENT FOR DISPLAY BAND ORIGIN
Dim bandOriginDropd own
On Error Resume Next
set scraper = Server.CreateOb ject("Microsoft .XMLHTTP")
if err then
bandOriginDropd own = ""
else
scraper.open "GET", path &
"/includes/soa_form_elemen t_plugin.inc.as p", false
scraper.send "tableID=2&fiel dID=1&typeID=0"
bandOriginDropd own = scraper.Respons eText
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) = "bandDescriptio n"
Dim formElementType Array(3)
formElementType Array(0) = "dropdown"
formElementType Array(1) = "text"
formElementType Array(2) = "textarea"
formElementType Array(3) = "hidden"
[/ASP]
Here is the ASP script soa_form_elemen t_plugin.inc.as p:
[ASP]
<!--#include virtual=/soa/includes/val_global_vars _functions.asp -->
<%
''''''''''''''' ''''''''''''''' ''''''''''''''' ''''''''''''''' '''''
' file: soa_form_elemen t_plugin.inc.as p
'
' created by: Phil Powell on 7/24/2005 '
' '
' Produce a dropdown list of band-related items whereby the '
' Request.QuerySt ring 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(Reque st.QueryString( "tableID")) then tableName =
tableNameArray( Request.QuerySt ring("tableID") )
if IsNumeric(Reque st.QueryString( "tableID")) and
IsNumeric(Reque st.QueryString( "fieldID")) then
myField = fieldArray(Requ est.QueryString ("tableID"),
Request.QuerySt ring("fieldID") )
end if
if IsNumeric(Reque st.QueryString( "typeID")) then myElementType =
formElementType Array(Request.Q ueryString("typ eID"))
Response.Write( "tableID = " & Request.QuerySt ring("tableID") )
if not IsNull(myField) and myField <> "" and not IsNull(tableNam e)
and tableName <> "" then
Dim Conn, rs
Set Conn = Server.CreateOb ject("ADODB.Con nection")
Conn.Open "DRIVER={Micros oft Access Driver (*.mdb)}; DBQ=" &
Server.MapPath( "\soa\db\sub.md b")
sql = "SELECT DISTINCT " & myField & " " &_
"FROM " & tableName & " " &_
"WHERE " & myField & " IS NOT NULL" &_
" AND " & myField & " <> '' " &_
"ORDER BY " & myField & " ASC"
set rs = Conn.execute(sq l)
if strcomp(lcase(m yElementType), "text") = 0 then
%>
<input name="my_<%= myField %>" size="50" maxlength="255" value="<%=
Replace(Request .Form("my_" & myField), """", """) %>">
<%
elseif strcomp(lcase(m yElementType), "textarea") = 0 then
%>
<textarea name="my_<%= myField %>" rows="8" cols="40"><%=
Replace(Request .Form("my_" & myField), "<", "<") %></textarea>
<%
elseif strcomp(lcase(m yElementType), "hidden") = 0 then
%>
<input type="hidden" name="my_<%= myField %>" value="<%=
Replace(Request .Form("my_" & myField), """", """) %>">
<%
elseif strcomp(lcase(m yElementType), "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 = 2Could 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