Skip to main content
Inspiring
March 27, 2014
Answered

trigger onchange event by load server data

  • March 27, 2014
  • 1 reply
  • 855 views

I have following code to filter my second list from my list.

It works when user click the dropdown, since onchange event trigger.

I tried to load the data from stored procedure then the onchange event does not trigger, when user need update data then will see whole list without filtering.

I would like to know if it is possible to trigger onchange event when I load data from stored procedure,

Your help and information is great appreciated,

Regards,

Iccsi,

<td><select name="Mylst" id="Mylst">

         <cfoutput query="MySP">

                  <option value="#MySP.MyID#"

          <cfif (isDefined("form.MyID") AND form.MyID EQ MySP.MyID)>selected="selected"</cfif>> #MySP.MyName# </option>

          </cfoutput>

     </select></td>

$("#Mylst").change(function()

        {    $.ajax({

                     type: "GET",

                     url:   'Mycfc.cfc?method=GetMethod&MyParam='+ jQuery("#MyPrelsty").val(),

                     dataType: "json",

             cache: false,

                     success: function(data)

                     {

              $('#MySublst option').remove();

         $.each(data, function(i, obj)

                  {

             $("#MySublst").append('<option value=' + '"' + data[0] + '"' +'>' + data[1] +

'</option>')

           });

         }  

   });

    This topic has been closed for replies.
    Correct answer BKBK

    iccsi wrote:

    I would like to know if it is possible to trigger onchange event when I load data from stored procedure,

    Yes, it is of course possible. The environment in which the event takes place - the browser - is independent of the environment in which data is loaded from the stored procedure - the ColdFusion server.

    Any problem you face are probably JQuery ones. A similar question was answered in Stackoverflow.

    1 reply

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    March 28, 2014

    iccsi wrote:

    I would like to know if it is possible to trigger onchange event when I load data from stored procedure,

    Yes, it is of course possible. The environment in which the event takes place - the browser - is independent of the environment in which data is loaded from the stored procedure - the ColdFusion server.

    Any problem you face are probably JQuery ones. A similar question was answered in Stackoverflow.

    iccsiAuthor
    Inspiring
    March 29, 2014

    Thanks for the information and help,

    Regards,

    Iccsi,