P
Phil Powell
[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), """", """) %>">
<%
elseif strcomp(lcase(myElementType), "textarea") = 0 then
%>
<textarea name="my_<%= myField %>" rows="8" cols="40"><%=
Replace(Request.Form("my_" & myField), "<", "<") %></textarea>
<%
elseif strcomp(lcase(myElementType), "hidden") = 0 then
%>
<input type="hidden" name="my_<%= myField %>" value="<%=
Replace(Request.Form("my_" & myField), """", """) %>">
<%
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:
However, if I call the URL directly
http://www3.brinkster.com/soa/includes/soa_form_element_plugin.inc.asp?tableID=2&fieldID=1&typeID=0
This is what I get:
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
'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), """", """) %>">
<%
elseif strcomp(lcase(myElementType), "textarea") = 0 then
%>
<textarea name="my_<%= myField %>" rows="8" cols="40"><%=
Replace(Request.Form("my_" & myField), "<", "<") %></textarea>
<%
elseif strcomp(lcase(myElementType), "hidden") = 0 then
%>
<input type="hidden" name="my_<%= myField %>" value="<%=
Replace(Request.Form("my_" & myField), """", """) %>">
<%
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/includes/soa_form_element_plugin.inc.asp?tableID=2&fieldID=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