1

従来のASPでコーディングしており、ADOを使用してデータベースにアクセスしています。私は2つの選択フィールドを持っています。

<select name="NBSCourse" class="NBSCourse"></select>
<select name="IndexNo" class="IndexNo"></select>

「NBSCourse」の場合、オプションフィールドはSQLリクエストを介して入力され、利用可能なすべてのコースコードの個別の結果が一覧表示されます。「NBSCourse」の選択された値に基づいて、次の選択フィールド「IndexNo」にデータを入力したいと思います。

現時点では、次のことを試しました。nbsCourseid用に選択したフィールドをASPファイル「indexnodrop」に渡す

$("select.NBSCourse").change(function () {
var nbsCourseid;
nbsCourseid = $("select.NBSCourse").val();

 $.ajax({url:"indexnodropdown.asp?q="+nbsCourseid,success:function(result) { 

    $("select.IndexNo").html(result);

}})

 })

indexnodrop.aspで、データベースにスクリプトを実行するために送信しました。

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

ここに欠けているものはありますか?よろしくお願いします!

4

1 に答える 1

0
$("select[name=NBSCourse]").change(function () {
  var nbsCourseid;
  nbsCourseid = this.value; // or $(this).value();
   $.ajax({url:"indexnodropdown.asp?q="+nbsCourseid,success:function(result) { 
     $("select[name=IndexNo]").html(result);
  }};
});

使用できません

select.NBSCourse.アクセスに表記が使用されているが、属性classを使用しているためname

コメントによると

を使用する場合はclass、代わりにをname使用できます

$("select.NBSCourse").change(function () {
  var nbsCourseid;
  nbsCourseid = this.value; // or $(this).value();
   $.ajax({url:"indexnodropdown.asp?q="+nbsCourseid,success:function(result) { 
     $("select.IndexNo").html(result);
  }};
})
于 2012-06-11T17:41:51.997 に答える