Solved

force the jquary change function

Posted on 2014-03-04
2
208 Views
Last Modified: 2014-03-04
I'm working on a mysql/php form. I am repopulating the form on page load.  My question is how do I force the change function in the ajax function, which is used in a dependent select box.

 The Ajax script is:

<script type="text/javascript">// Dynamic Support Select based on Depth
           $(document).ready(function(){
                     $("#Depth").change(function(){
                     var depth=$("#Depth").val();
                     $.ajax({
                        type:"post",
                        url:"support_get.php",
                        data:"depth="+depth,
                        success:function(data){
                              $("#A_Sup").html(data);
                                            $("#B_Sup").html(data);
                        }      
                     });
            
               });
           });
            
      </script>


The function to repopulate the page steps through the form setting values based on saved values in the mysql table. I was setting the value of 'Depth' and then trying to trigger as follows, but it doesn't fire. ???


      form1.Depth.value="<?php echo $row_Quote['Depth']; ?>";

      $("Depth").trigger("change");
            
      setSelectedIndex_val(document.getElementById("A_Sup"),"<?php echo $row_Quote['A_Sup']; ?>");
      setSelectedIndex_val(document.getElementById("B_Sup"),"<?php echo $row_Quote['B_Sup']; ?>");
0
Comment
Question by:jws2bay
2 Comments
 
LVL 22

Accepted Solution

by:
Snarf0001 earned 500 total points
ID: 39904400
If the code above is correct, you're just missing the #

$("Depth").trigger("change");
-- change to --
$("#Depth").trigger("change");
0
 

Author Comment

by:jws2bay
ID: 39904639
That's it.  Works fine.

Thanks
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
website content maintenance 3 57
Problem to echo 6 53
Suggestion on WebSite Template Sites 5 51
razorCMS: Change Menu Font 4 24
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now