Solved

force the jquary change function

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

717 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