how can I load one php file in div when I click a button which is in another file div

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harini0590
    New Member
    • Apr 2012
    • 19

    how can I load one php file in div when I click a button which is in another file div

    i use this jquery in order to load the another file.and also for implementing jquery we need to include something else other than jquery.js...
    Code:
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("#button").click(function(){
        $("#sem_content_right").slideToggle();
    	$("#two").load('chief_input_form.php');
      });
    });
    and my html part is
    Code:
    <div id="sem_con_wrapper">
    <div id="sem_content_left">
    <?php include("sem_input_form.php"); 
    ?>
    </div>
    <div id="sem_content_right">
    <?php include("chief_input_form.php");
    ?>
    <input type="button" value="ONE MORE" id="buttton" />
    </div>
    <div id="two" style="background-color:#066; height:500px; width:330px;>
    </div>
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    how can i load one php file in div when i click a button which is in another file div
    why should that matter? you have a button, you attach an event handler to it, that handler inserts code somewhere. I don’t see a conflict between <div>s anywhere.

    Comment

    • harini0590
      New Member
      • Apr 2012
      • 19

      #3
      I use some function like when the document is load it have to call some other function.. when i remove that function the above coding is works.. is it any problem in that
      Code:
      window.onload=start();
      In start(); i have to call some other function like that my coding proceed.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        a) window.onload = start(); immediately executes the function and does not wait for the load event

        b) yes, a second window.onload would overwrite the first one. use Event Listeners (addEventListen er()) to circumvent that.

        Comment

        • harini0590
          New Member
          • Apr 2012
          • 19

          #5
          thanks, the coding works.but i didnt use addEventListene r().what is the purpose of this.

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            allowing more than one handler for an event.

            Comment

            • harini0590
              New Member
              • Apr 2012
              • 19

              #7
              is this is a format for the addEventListene r()...
              Code:
              function func1() {
                alert("This is the first.");
              }
              function func2() {
                alert("This is the second.");
              }
              
              function addLoadEvent(func) {
                var oldonload = window.onload;
                if (typeof window.onload != 'function') {
                  window.onload = func;
                } else {
                  window.onload = function() {
                    if (oldonload) {
                      oldonload();
                    }
                    func();
                  }
                }
              }
              addLoadEvent(func1);
              addLoadEvent(func2);
              addLoadEvent(function() {
                  document.body.style.backgroundColor = '#EFDF95';
              })

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #8
                hm, yea. a complicated way of expressing 3 lines of code without full support of the event flow (no event capturing possible) or even the usability of the Event object or the this keyword.

                and if I (or another script) do window.onload = func3; all previous assignments are lost.

                Comment

                Working...