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

  • SEARCH
  • Home
  • 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 5964445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:26:03+00:00 2026-05-22T19:26:03+00:00

I am trying to get two change functions to run, one when one select

  • 0

I am trying to get two change functions to run, one when one select box is changed, the other when another select box is changed.

$(document).ready(function() {      
        $("#area").change(function() { 
                $.ajax(
                {
                    type:"POST",
                    url: "./includes/AJAX/getFunctions.cfm?areaID=" + $(this).val(),
                    cache: false,
                    success: function(html)
                    {
                        $("#functions").html(html)
                    }
                }); //end of AJAX call
        }); //end of area

        $("#function").change(function() {
            alert("Change"); 
                $.ajax(
                {
                    type:"POST",
                    url: "./includes/AJAX/getDefects.cfm?functionID=" + $(this).val() + "&areaID=" + $("#area").val(),
                    cache: false,
                    success: function(html)
                    {
                        $("#defects").html(html)
                    }
                }
                );
        }); 
    });

I am only able to get the first function to run, but the second never does. I use firebug to just make sure there is not an error in syntax, but it never reaches the code. Anyone have any ideas what is happening?

Here are my select boxes in my html:

 <tr>
                        <td align="right">
                            Business Area:
                        </td>
                        <td align="left">
                            <cfselect name="area" id="area">
                            <option value="">Select Business Area</option>
                        <cfloop query="getAreas">
                            <option value="#getAreas.areaID#">#getAreas.areaDesc#</option>
                        </cfloop>
                            </cfselect>
                        </td>
                    </tr>
                    <!--- Business Function --->
                    <tr id="trFunction" style="display:none">
                        <td align="right">
                            Business Function:
                        </td>
                        <td align="left">
                        <div id="functions">
                            <select name="functionID" id="functionID">
                                <option value="">Select Business Function</option>
                            </select>
                         </div>
                        </td>
                    </tr>
                    <!--- Defect Type --->
                    <tr id="trDefect" style="display:none">
                        <td align="right">
                            Defect Type:
                        </td>
                        <td align="left">
                        <div id="defects">
                            <select name="defect" id="defect">
                                <option value="">Select Defect</option>
                            </select>
                         </div>
                        </td>
                    </tr>

And here are the queries:

<cfquery name="getFunctions" datasource=#application.datasource#>     
    SELECT *
    FROM lamFunctions
    WHERE status = 1
    AND areaID = '#url.areaID#'
    ORDER BY functionDescription        
</cfquery>

<cfoutput>
    <select name="functionID" id="functionID">
        <option value="">Select Business Function</option>
    <cfloop query="getFunctions">
        <option id="#functionID#" name="#functionDescription#" value="#functionID#">#functionDescription#</option>
    </cfloop>
    </select>   
</cfoutput>

<cfquery name="getDefects" datasource=#application.datasource#>     
    SELECT *
    FROM lamDefects
    WHERE status = 1
    AND areaID = '#url.areaID#'
    AND functionID like '%#url.functionID#%'
    ORDER BY defectDesc        
</cfquery>

<cfoutput>
    <cfif #url.functionID# eq 3>
        <select name="defect" id="defect" style="width:350px">
            <option value="">Select Defect</option>
        <cfloop query="getDefects">
            <option id="#defectID#" name="#defectDesc#" value="#defectID#">#defectDesc#</option>
        </cfloop>
        </select>
    <cfelse>
        <select name="defect" id="defect">
            <option value="">Select Defect</option>
        <cfloop query="getDefects">
            <option id="#defectID#" name="#defectDesc#" value="#defectID#">#defectDesc#</option>
        </cfloop>
        </select>
    </cfif>    
</cfoutput>
  • 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-22T19:26:04+00:00Added an answer on May 22, 2026 at 7:26 pm

    First thing that I see is that you are calling second change function on $(“#function”) whereas the Id of your second select statement is functionID. Second thing is that event handlers registered in document.ready function only apply to elements that are already loaded on the page. for elements that are added later you can use

    $("#functionID").live('change', function(){
    //handle event
    });
    

    but using change event with live caused some problems for me on different browsers (IE especially). so another option could be using livequery library of jQuery or you can register the event handler on callback of your first ajax request like

    $("#area").change(function() { 
                    $.ajax(
                    {
                        type:"POST",
                        url: "./includes/AJAX/getFunctions.cfm?areaID=" + $(this).val(),
                        cache: false,
                        success: function(html)
                        {
                            $("#functions").html(html)
                            $("#functionID").change(function(){
                                //handle event here                       
                             });
                        }
                    }); //end of AJAX call
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get my head around this one: Say you have two models
Im trying to get two alpha-24 transparent .png files to crossfade into each other.
When I run the decorate_keyword() function below, I'm getting two errors that I'm trying
In my GWT project, I'm trying to get it so two DialogBoxes can pass
I'm trying to get crawl to work on two separate farms I have but
I'm trying to get a case-insensitive search with two strings in JavaScript working. Normally
I'm trying to get the dates from entries in two different RSS feeds through
I'm trying to compare two datetimes but I can't get it to work. public
I'm trying to figure out how to get only the last two files within
I'm trying to achieve two things, both of which I fail to get at.

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.