longmatch
Programmer
- Nov 1, 2001
- 406
Dear All:
I have got a piece of code written in ASP and javascript to populate two linked-combo box based upon recordset from a database. Do you think I can see the html output which derived from ASP server side?
Thanks
Haijun
see my code below:
<!--#include file="Clssfdpage.asp"-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="f1">
<%
Set rsX = Server.CreateObject("ADODB.Recordset"
sQuery = "SELECT category AS name, procedure AS model, " & _
"categoryID AS ManuID, procedureID AS ModelID " & _
"FROM CategoryProcedure"
rsX.Open sQuery, objConn, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If rsX.EOF Then
Response.Write "No manufacturers.<BR>"
Else
' write the manufacturers listbox...
Response.Write "<SELECT NAME=""manufacturer"" " & _
" ONCHANGE=""manuselected(this);"" >"
' write the entry code for the javascript...
sJavaScript = "function manuselected(elem){" & vbCrlf & _
"for (var i = document.f1.model." & _
"options.length; i >= 0; i--){" & vbCrlf & _
"document.f1.model.options = null;" & _
vbCrlf
' loop through the recordset...
Do Until rsX.EOF
' is this a new manufacturer?
If sLastManufacturer <> rsX("Name" Then
' if so, add an entry to the first listbox
sLastManufacturer = rsX("Name"
Response.Write "<OPTION VALUE=" & rsX("ManuID" & _
">" & sLastManufacturer & "</OPTION>"
' and add a new section to the javascript...
sJavaScript = sJavaScript & "}" & vbCrlf & _
"if (elem.options[elem.selectedIndex].value==" & _
rsX("ManuID" & "{" & vbCrlf
End If
' and add a new model line to the javascript...
sJavaScript = sJavaScript & _
"document.f1.model.options[document." & _
"f1.model.options.length] = new Option('" & _
rsX("Model" & "','" & rsX("ModelID" & _
"');" & _
vbCrlf
rsX.MoveNext
Loop
' finish the manufacturer listbox...
Response.Write "</SELECT><br>"
' create the models listbox...
Response.Write "<SELECT NAME=""model"">"
Response.Write "<OPTION>[none currently selected]</OPTION>"
Response.Write "</SELECT>"
' put the last line on the javascript...
' and write it out...
sJavaScript = sJavaScript & vbCrlf & "}" & vbCrlf & _
"}" & vbCrlf
Response.Write "<SCRIPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write sJavaScript & vbCrlf & "</SCRIPT>" & vbCrlf
End If
rsX.Close
Set rsX = Nothing
%>
</form>
</BODY>
</HTML>
I have got a piece of code written in ASP and javascript to populate two linked-combo box based upon recordset from a database. Do you think I can see the html output which derived from ASP server side?
Thanks
Haijun
see my code below:
<!--#include file="Clssfdpage.asp"-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form name="f1">
<%
Set rsX = Server.CreateObject("ADODB.Recordset"
sQuery = "SELECT category AS name, procedure AS model, " & _
"categoryID AS ManuID, procedureID AS ModelID " & _
"FROM CategoryProcedure"
rsX.Open sQuery, objConn, adOpenForwardOnly, _
adLockReadOnly, adCmdText
If rsX.EOF Then
Response.Write "No manufacturers.<BR>"
Else
' write the manufacturers listbox...
Response.Write "<SELECT NAME=""manufacturer"" " & _
" ONCHANGE=""manuselected(this);"" >"
' write the entry code for the javascript...
sJavaScript = "function manuselected(elem){" & vbCrlf & _
"for (var i = document.f1.model." & _
"options.length; i >= 0; i--){" & vbCrlf & _
"document.f1.model.options = null;" & _
vbCrlf
' loop through the recordset...
Do Until rsX.EOF
' is this a new manufacturer?
If sLastManufacturer <> rsX("Name" Then
' if so, add an entry to the first listbox
sLastManufacturer = rsX("Name"
Response.Write "<OPTION VALUE=" & rsX("ManuID" & _
">" & sLastManufacturer & "</OPTION>"
' and add a new section to the javascript...
sJavaScript = sJavaScript & "}" & vbCrlf & _
"if (elem.options[elem.selectedIndex].value==" & _
rsX("ManuID" & "{" & vbCrlf
End If
' and add a new model line to the javascript...
sJavaScript = sJavaScript & _
"document.f1.model.options[document." & _
"f1.model.options.length] = new Option('" & _
rsX("Model" & "','" & rsX("ModelID" & _
"');" & _
vbCrlf
rsX.MoveNext
Loop
' finish the manufacturer listbox...
Response.Write "</SELECT><br>"
' create the models listbox...
Response.Write "<SELECT NAME=""model"">"
Response.Write "<OPTION>[none currently selected]</OPTION>"
Response.Write "</SELECT>"
' put the last line on the javascript...
' and write it out...
sJavaScript = sJavaScript & vbCrlf & "}" & vbCrlf & _
"}" & vbCrlf
Response.Write "<SCRIPT LANGUAGE=""JavaScript"">" & vbCrlf
Response.Write sJavaScript & vbCrlf & "</SCRIPT>" & vbCrlf
End If
rsX.Close
Set rsX = Nothing
%>
</form>
</BODY>
</HTML>