|
-
ASP and Dynamically Updating Combo Box
Here's the situation. I need to create two combo boxes, using ASP and VBScript to fill the information from a database. The second combo box's information depends on what has been selected in the first combo box. When the user selects something in the first combo box, the OnClick property triggers the UpdateSecondCB() function using VBScript. Now my problem lies in accessing the database. I've tried the regular way of(located below) accessing the database, but this doesn't work. Is there a special way to access a database in a function?
btw, I'm getting the error "Object Required: 'Server'" at the </body> statement. This function is located inside of the <body> field.
<script language="VBScript">
sub UpdateSecondCB
WhatIWant = clng(FORM.OPTION.value)
set conn = server.createobject("ADODB.Connection")
conn.open "MyDatabase","",""
set recordset = server.createobject("ADODB.Recordset")
strSQL = "SELECT FieldName, FieldID FROM Table WHERE Field1ID = " & WhatIWant & ";"
recordset.open strSQL, conn, 3, 3
While Not recordset.EOF
set objOption = document.createElement("OPTION")
objOption.Value = recordset.Fields("FieldID")
objOption.Text = recordset.Fields("FieldName")
Search.Topics.add objOption
recordset.MoveNext
WEnd
recordset.Close
conn.Close
set conn = Nothing
set recordset = Nothing
end sub
</script>
I've searched many web sites trying to find some information, this is my last resort.
------------------
- jeste®
How could tomorrow ever follow today?
- jeste®
How could tomorrow ever follow today?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|