Solved

force the jquary change function

Posted on 2014-03-04
2
215 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 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
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…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

756 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