?
Solved

force the jquary change function

Posted on 2014-03-04
2
Medium Priority
?
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 2000 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

Use Filtering Commands to Process Files in Linux

Learn how to manipulate data with the help of various filtering commands such as `cat`, `fmt`, `pr`, and others in Linux.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

752 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