hi all
i have two question,first of all,i have 4 php documents so for example i need to access doc2.php 'div' element.i've got no idea about this!😕:queasy:
and second question is about calling function by 'onclick' event,i know this question asked many time but i didn't find any good solution about that and
this question wasted too much time(about one week!) without any good solution.😕
so any help would be appreciated.
skynix1900

    skynix1900;11039695 wrote:

    i have 4 php documents so for example i need to access doc2.php 'div' element.

    PHP scripts don't have 'div' elements. Are you saying that one of your four PHP scripts either returns or outputs some HTML data that, when parsed, results in a 'div' element appearing... somewhere... in the DOM? I'm not sure I understand what you're saying here, to be honest.

    Assuming that you can answer the above question... what does it mean to "access" such an element? Access it in what way, or for what purpose?

    skynix1900;11039695 wrote:

    second question is about calling function by 'onclick' event,i know this question asked many time but i didn't find any good solution about that and
    this question wasted too much time(about one week!) without any good solution.

    I also don't have any good solution to offer you... but that's only because you never actually asked a question or described a problem.

      I'm guessing maybe the second part is referring to the sort of thing you'd do with AJAX, having JavaScript call a PHP script on the server? But yeah, I'm just guessing here.

        bradgrafelman;11039699 wrote:

        PHP scripts don't have 'div' elements. Are you saying that one of your four PHP scripts either returns or outputs some HTML data that, when parsed, results in a 'div' element appearing... somewhere... in the DOM? I'm not sure I understand what you're saying here, to be honest.

        Assuming that you can answer the above question... what does it mean to "access" such an element? Access it in what way, or for what purpose?

        I also don't have any good solution to offer you... but that's only because you never actually asked a question or described a problem.

        my mistake,yes,on of my four php scripts return outputs and i use all of them like this:
        <?php include 'TopMenu.php';?>
        <?php include 'LertSidebar.php';?>
        <?php include 'RightSidebar.php';?>
        <?php include 'MainContent.php';?>
        <?php include 'Footer.php';?>
        and in 'MainContent.php' there is hidden "<div">(#dvMainContent) that i need to change that innerhtml so as you say its only html object in php file.and i want to know how can i change that "<div>" innerhtml?
        and for second question i want to execute php function when user click on button(without any form).i've got plenty of buttons,i use some solution but their just make my document more and more complex!This is one sample code that execute php function:
        function Samplefunction()
        {
        echo "<script>alert('worked!')</script>";

        }
        if (isset($_GET['sEvent'][1]))
        {
        Samplefunction();
        }

        and for HTML code in PHP document:
        <a href="Document.php?sEvent[1]=true"><h5 id="btnTrigger" class="RightSideBarItem">Click On Here.</h5></a>

        sorry for taking your time.hope this help to understand my question.

          skynix1900;11039703 wrote:

          in 'MainContent.php' there is hidden "<div">(#dvMainContent) that i need to change that innerhtml so as you say its only html object in php file.and i want to know how can i change that "<div>" innerhtml?

          You can use javascript. This is not something that PHP can do.*

          skynix1900;11039703 wrote:

          i want to execute php function when user click on button(without any form).

          Again, you can use javascript* (AJAX). There are javascript libraries (jQuery, for example) that make using AJAX a little simpler and less painful.

          AJAX won't let you "jump" back into the same script, however. It will allow you to create a new request, and whatever PHP script you run will run fresh, from the beginning. You will probably have to re-think how your scripts are arranged.

          * It would seem you misunderstand how PHP works. PHP code runs First, on your server. The [font=monospace]<div>[/font] you're talking about is not an "html object in a php file": it is just "text", as far as PHP is concerned, nothing more. PHP outputs this text to the user's browser.

          Later, once we get to the browser, that output text is interpreted as HTML markup (or javascript, css, etc.) and used to create the webpage. Now, there are HTML elements in the DOM, javascript runs, and so forth: but there is no such thing as "PHP."

            traq;11039705 wrote:

            You can use javascript. This is not something that PHP can do.*

            Again, you can use javascript* (AJAX). There are javascript libraries (jQuery, for example) that make using AJAX a little simpler and less painful.

            AJAX won't let you "jump" back into the same script, however. It will allow you to create a new request, and whatever PHP script you run will run fresh, from the beginning. You will probably have to re-think how your scripts are arranged.

            * It would seem you misunderstand how PHP works. PHP code runs First, on your server. The [font=monospace]<div>[/font] you're talking about is not an "html object in a php file": it is just "text", as far as PHP is concerned, nothing more. PHP outputs this text to the user's browser.

            Later, once we get to the browser, that output text is interpreted as HTML markup (or javascript, css, etc.) and used to create the webpage. Now, there are HTML elements in the DOM, javascript runs, and so forth: but there is no such thing as "PHP."

            thank you for your reply,traq.well,how can i access that element with javascript and then excute php function?i mean i want to change '#dvMainContent' innerhtml to specific text and then excute php function.

            for question 2:
            i want to read some data and show them in specific form when user click on "Show" button.so can you please show me example?i really dont know what other php developers do when they want to declare "onclick" event in php for simple button!:queasy:
            anyway,thanks for your reply again.

              Write a Reply...