I’m coding in classic ASP, and using ADO to access my database. I have two select fields, namely:
<select name="NBSCourse" class="NBSCourse"></select>
<select name="IndexNo" class="IndexNo"></select>
For “NBSCourse”, the option fields are being populated via SQL request, listing distinct results of all available course codes. I would like to populate the next select field “IndexNo”, based on the selected value of “NBSCourse”.
At the moment, I’ve tried the following: passing the selected field for nbsCourseid to the ASP file “indexnodrop
$("select.NBSCourse").change(function () {
var nbsCourseid;
nbsCourseid = $("select.NBSCourse").val();
$.ajax({url:"indexnodropdown.asp?q="+nbsCourseid,success:function(result) {
$("select.IndexNo").html(result);
}})
})
In indexnodrop.asp , I’ve sent in to execute the script into the database.
dim selectedcourseID
selectedcourseID = Request.querystring("q")
oCmd.CommandText = "SELECT DISTINCT IndexNo FROM NBSCourse WHERE CourseId='" & selectedcourseID & "'"
Set oRS = oCmd.Execute()
If Not oRS.EOF Then
response.write("<option value='" & oRS("IndexNo") & "'>" & oRS("IndexNo") & "</option>")
End If
Is there something I’m missing here? Thanks in advance for your help!
You can’t use
select.NBSCoursebecause.notation used for accessclass, but you’ve usednameattribute.According to comment
if you use
class, instead ofnamethen you can use