Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 767955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:06:22+00:00 2026-05-14T18:06:22+00:00

I am working on a classic asp form that has a number of dropdowns.

  • 0

I am working on a classic asp form that has a number of dropdowns. Three of these are cascading, i.e. they rely in the previous dropdown. For almost everything this code works fine, one of them however is not playing nice.

To start off I have a script tag with the following in it:

    $(document).ready(function () {
        $("#AcademicLevel").change(getList);
        $("#CourseDeliveryTime").change(updateLocation);
        $("#ProgramType").change(updateEntryTerm);
    });

This works just fine for the first two elements of the form, AcademicLevel and CourseDeliveryTime, the third however does not take effect however. If I use Firebug’s Console and run that same line of code, $(“#ProgramType”).change(updateEntryTerm);, it starts to work, sort of.

What happens is what confuses me. If the function it is pointing to, updateEntryTerm, has an alert() call in it, it works. If the alert is commented out, it does not work. The function is below:

    function updateEntryTerm() {
        $.ajax({
            type: "POST",
            url: "../Classic ASP and AJAX/jQueryExample.asp",
            dataType: "application/x-www-form-urlencoded",
            data: "Action=UpdateEntryTerm&acadLevel=" + $("#AcademicLevel").val() + "&courseTime=" + $("#CourseDeliveryTime").val() + "&programType=" + $("#ProgramType").val(),
            async: false,
            success: function (msg) {
                $("#EntryTerm").remove();
                $("#tdEntryTerm").append(msg);
                //alert(msg);
            } //,
            //error: function (xhr, option, err) {
            //    alert("XHR Status: " + xhr.statusText + ", Error - " + err);
            //}
        });
    }

I am lost on two different issues here, First why is the call to $(“#ProgramType”).change(updateEntryTerm); not working unless I run it in Firebug Console? Second, why does the function itself, updateEntryTerm, not work unless the alert() call is present?

Has anyone seem something like this before?

EDIT: The full javascript is here:

<script type="text/javascript" language="javascript">
//<![CDATA[

    $(document).ready(function () {
        $("#AcademicLevel").change(getList);
        $("#CourseDeliveryTime").change(updateLocation);
        $("#ProgramType").change(updateEntryTerm);            
        //alert("DOM loaded!");
        //$("#CourseDeliveryTime").change(updateEntryTerm);
    });

    // Function to get ProgramofInterest list
    function getList() {
        $.ajax({
            type: "POST",
            url: "../Classic%20ASP%20and%20AJAX/jQueryExample.asp",
            dataType: "application/x-www-form-urlencoded",
            data: "Action=GetList&Val=" + $("#AcademicLevel").val(),
            async: false,
            success: function (msg) {
                //$("label[id$=Two]").add("select[id$=Two]").remove();
                $("#ProgramofInterest").remove();
                $("#tdProgramOfInterest").append(msg);
            }
        });
    }

    function updateLocation() {
        $.ajax({
            type: "POST",
            url: "../Classic%20ASP%20and%20AJAX/jQueryExample.asp",
            dataType: "application/x-www-form-urlencoded",
            data: "Action=UpdateLocation&acadLevel=" + $("#AcademicLevel").val() + "&courseTime=" + $("#CourseDeliveryTime").val(),
            async: false,
            success: function (msg) {
                //$("label[id$=Two]").add("select[id$=Two]").remove();
                $("#ProgramType").remove();
                $("#tdProgramType").append(msg);
            } //,
            //error: function (xhr, option, err) {
            //    alert("XHR Status: " + xhr.statusText + ", Error - " + err);
            //}
        });
    }

    function updateEntryTerm() {
        $.ajax({
            type: "POST",
            url: "../Classic%20ASP%20and%20AJAX/jQueryExample.asp",
            dataType: "application/x-www-form-urlencoded",
            data: "Action=UpdateEntryTerm&acadLevel=" + $("#AcademicLevel").val() + "&courseTime=" + $("#CourseDeliveryTime").val() + "&programType=" + $("#ProgramType").val(),
            async: false,
            success: function (msg) {
                $("#EntryTerm").remove();
                $("#tdEntryTerm").append(msg);
                //alert(msg);
            } //,
            //error: function (xhr, option, err) {
            //    alert("XHR Status: " + xhr.statusText + ", Error - " + err);
            //}
        });
    }
//]]>
</script>

This is the code for the ProgramType form field that should be getting the change event:

    <td id="tdProgramType">
        <!--<span id="prefLoc">
            <select id="ProgramType" name="ProgramType" onchange="changeStartTerm()">
                <option value="" >&lt;select above options first&gt;</option>
            </select>
        </span>-->
        <%
            Dim outputProgramTypes                                    

            outputProgramTypes = outputProgramTypes + "<select name=""ProgramType"" id=""ProgramType""><option value=''>&lt;Select&gt;</option>"

            Set oRs=Server.CreateObject("adodb.recordset")

            'if Request.Form("AcademicLevel") = "undergraduate" and Request.Form("CourseDeliveryTime") = "Day" then
                strSQL = "SELECT LocationName, LocationCode FROM tbLocations ORDER BY LocationWeight ASC"
            'else
            '    strSQL = "SELECT LocationName, LocationCode FROM tbLocations WHERE LocationWeight < 3 ORDER BY LocationWeight ASC"
            'end if

            oRs.Open strSQL, conn

            Do while not oRs.EOF               
                outputProgramTypes = outputProgramTypes + "<option value = '" & oRS ("LocationCode") & "'>"
                outputProgramTypes = outputProgramTypes + oRs("LocationName") & "</option>"
                oRs.MoveNext
            loop

            outputProgramTypes = outputProgramTypes + "</select>"

            Response.Write(outputProgramTypes)
        %>
    </td>
</tr>

And this is the code from the post page that does the work of switching the items in the list:

<%

' Get the variables from the query string
dim act 
act = lcase(Request("Action"))
dim value 
value = Request("Val")

dim acadLevel, courseTime, programType
acadLevel = Request("acadLevel")
courseTime = Request("courseTime")
programType = Request("programType")

Dim oRs, conn, connect, strSQL

set conn=server.CreateObject ("adodb.connection")
connect = "Driver=SQL Server;Server=(local);Database=leads;UID=x;PWD=x;"
conn.Open connect

' Route based on the action
if act = "getlist" then
    GetProgramList(value)
elseif act = "updatelocation" then
    UpdateLocation acadLevel, courseTime
elseif act = "updateentryterm" then
    UpdateEntryTerm acadLevel, courseTime, programType
end if

' Gets the list of programs for the ProgramofInterest dropdown.
sub GetProgramList(val)
    dim outputPrograms

    outputPrograms = outputPrograms + "<select style=""width:431px;"" id=""ProgramofInterest""><option value=''>&lt;Select&gt;</option>"

    Set oRs=Server.CreateObject("adodb.recordset")

    Select Case val
        Case "undergraduate"
            strSQL = "SELECT ProgramCode, ProgramName FROM tbPrograms WHERE ProgramLevel = 'UG' ORDER BY ProgramWeight ASC, ProgramType ASC, ProgramName ASC"
        Case "graduate"
            strSQL = "SELECT ProgramCode, ProgramName FROM tbPrograms WHERE ProgramLevel = 'GR' ORDER BY ProgramWeight ASC, ProgramType ASC, ProgramName ASC"
        Case Else
            strSQL = "SELECT ProgramCode, ProgramName FROM tbPrograms ORDER BY ProgramWeight ASC, ProgramType ASC, ProgramName ASC"
    End Select

    oRs.Open strSQL, conn

    Do while not oRs.EOF               
        outputPrograms = outputPrograms + "<option value = '" & oRS ("ProgramCode") & "'>"
        outputPrograms = outputPrograms + oRs("ProgramName") & "</option>"
        oRs.MoveNext
    loop    

    outputPrograms = outputPrograms + "</select>"

    response.write(outputPrograms)  
end sub

sub UpdateLocation(level, time)
    Dim outputProgramTypes                                                  

    outputProgramTypes = outputProgramTypes + "<select name=""ProgramType"" id=""ProgramType""><option value=''>&lt;Select&gt;</option>"

    Set oRs=Server.CreateObject("adodb.recordset")

    'if Request.Form("AcademicLevel") = "undergraduate" and Request.Form("CourseDeliveryTime") = "Day" then    
    if level = "undergraduate" and time = "Day" then    
        strSQL = "SELECT LocationName, LocationCode FROM tbLocations WHERE LocationWeight < 3 ORDER BY LocationWeight ASC"        
    else
        strSQL = "SELECT LocationName, LocationCode FROM tbLocations ORDER BY LocationWeight ASC"
    end if

    oRs.Open strSQL, conn

    Do while not oRs.EOF               
        outputProgramTypes = outputProgramTypes + "<option value = '" & oRS ("LocationCode") & "'>"
        outputProgramTypes = outputProgramTypes + oRs("LocationName") & "</option>"
        oRs.MoveNext
    loop

    outputProgramTypes = outputProgramTypes + "</select>"

    Response.Write(outputProgramTypes)
end sub

sub UpdateEntryTerm(level, time, progType)
    Dim outputEntryTerms    

    outputEntryTerms = outputEntryTerms + "<select name=""EntryTerm"" id=""EntryTerm""><option value=''>&lt;Select&gt;</option>"

    Set oRs=Server.CreateObject("adodb.recordset")

    'if Request.Form("AcademicLevel") = "undergraduate" and Request.Form("CourseDeliveryTime") = "Day" and Request.Form("ProgramType") = "MAN" then
    if level = "undergraduate" and time = "Day" and progType = "MAN" then
        strSQL = "SELECT EntryTermName, EntryTermCode FROM tbEntryTerms WHERE ID < 7 ORDER BY EntryTermWeight ASC"
    else
        strSQL = "SELECT EntryTermName, EntryTermCode FROM tbEntryTerms WHERE ID = 7"        
    end if

    oRs.Open strSQL, conn

    Do while not oRs.EOF               
        outputEntryTerms = outputEntryTerms + "<option value = '" & oRS ("EntryTermCode") & "'>"
        outputEntryTerms = outputEntryTerms + oRs("EntryTermName") & "</option>"
        oRs.MoveNext
    loop

    outputEntryTerms = outputEntryTerms + "</select>"

    Response.Write(outputEntryTerms)
end sub

%>

Hopefully that helps you guys help me a little better. I didn’t add the full form because it is massive, and contains a ton of legacy code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:06:23+00:00Added an answer on May 14, 2026 at 6:06 pm

    I finally figured out the issue here, and it was pretty simple in the end.

    On document.ready I add a function call to the change event for one dropdown like so:
    $(“#ProgramType”).change(updateEntryTerm);

    Later on when that dropdown needs to be updated I remove it, then add it back to the page with the updated list. That is the problem. After removing it, I never did the call to add the function call to the change event again.

    Like I said very simple, just overlooked the process there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Been working on a classic asp page. I've been using Request.Form(x) and saw that
I'm working on an ASP.net 3.5 project that has evolved out of a Classic
I'm working on a Classic ASP (VBScript) site that's running on a Windows 2008
I'm working with classic ASP. I have an 2 includes that have 2 different
I'm working with a Classic ASP web app that typically runs well considering the
I am working on Classic ASP site. In one form results will be fetched
I'm working with a snippet of classic ASP code that sits in the menu
Recently I started working with MVC, before that I used classic ASP.NET. After using
I am working in a classic asp application that requires functionality that will modify
I'm working on updating a classic ASP web page used by a number of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.