I am trying to populate an drop down control with the recordset
results of an ADODB connection to a Access DB. The database/recordset
portion seems to be working fine. However, I'm not clear how to write
the Select <options>.
BACKGROUND
* I have modularized the DB open + close.... global var the
variables
function openDB() {
strConnection = "UID=;pwd=;DSN=reports;";
objConn = new ActiveXObject("ADODB.Connection");
objConn.open(strConnection);
objRS = new ActiveXObject("ADODB.Recordset");
}
function closeDB() {
objRS.Close();
objConn.Close();
}
* The onChange even triggers the following:
openDB();
strSqlData ="SELECT fld_example from tbl_example";
objRS.open(strSqlData, objConn);
while(!objRS.EOF) {
........ OK so far....how do I get the recordset
sequentially into the select?
<OPTION value="<%= rs("fld_example")%>"><%=
rs.Fields("fld_example")%></option>
<%
rs.movenext
Loop
%>
....??? VB how do wite that into the form using JS?
Any advice or examples would be greatly appreciated (other than RTFM).
Phil Morgan
// document.getElementById("year").[getElementById("year").length]=
new Option ("display string " + i, "value " + i);
// }
closeDB();
break;
Is the recordset "objRS" or "rs"?
I usually construct the string comletely:
var opts = "";
while(!objRS.EOF) {
opts += "<option value=" + objRS("fld_example") + ">" +
objRS.Fields("fld_example") + "</option>"
objRS.movenext
}
before using it:
<select>
<%=opts%>
</select>
Also, I usually use VBScript (instead of JScript) with ASP.
(Note sure what that code was after your signature.)