This is a multi-part message in MIME format.
------=_NextPart_000_0001_01C16B1B.CA06D920
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
I'm trying to collect the recordset into a JavaScript array and than
display the array into a combo box. The problem is that when using
JavaScript, I have no idea what goes where. (What goes into head of the
document, what in the body, how do I combine JavaScript with ASP
altogehter???
Here is the code that I'm having problems with. I would really
appreciate any kind of help here!
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
Dim objCmd, strSql, rs
%>
<script language="javascript">
<%
'this is where I'm getting an error "Expected end of statement, but
I'm sure it's not the statement itself that is 'the problem but the
way I place it in the document.
var myArray = new Array();
set objCmd = Server.CreateObject("ADODB.Command")
'I'm using interdev to define the connection and it's name is
Connection1
set objCmd.ActiveConnection = Connection1
objCmd.CommandType = adCmdText
objCmd.CommandText = strSql
strSql = "SELECT INDEPENDENT_ID, NAME FROM
CIS420F01B_CARS_INDEPENDENT ORDER BY INDEPENDENT_ID"
set rs = Connection1.Execute(strSql)
Do Until rs.EOF
Response.Write "myArray["
Response.Write rs("INDEPENDENT_ID") & "] = """
Response.Write rs("NAME")
Response.Write """;" & vbCrlf
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
%>
</script>
<script language="javascript">
function addArrayToCombo(){
var cbo = document.forms[0].mycombo;
for (var i = 0; i < myArray.length; i++){
if (myArray[i]){
cbo.options[cbo.options.length]
new Option(myArray[i], i);
}
}
}
</script>
<P> </P>
</BODY>
</HTML>