how to call function php($varible) into javascript withod ajax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • intermanch
    New Member
    • Jul 2010
    • 1

    how to call function php($varible) into javascript withod ajax

    how call function php($varible) into javascript withod ajax:

    Code:
    
    <!--
    this code only call funnctions php but
    how call function php[ function-name(varible)]
    intermanch@gmail.com
    www.intermanch.blogfa.com
    -->
    
    <script>
    function Helloo($f)
    {
    var t4 = document.createElement('div');
    t4.innerHTML ="<?php hello() ?>";
    document.getElementById('dl').appendChild(t4);
    }
    </script>
     
    <?php
    function hello()
    {
    //if on the java script can write function-name(varible) than can write echo varible;
    //echo $x;
    //help to complet this code
    echo "name: ";
    echo "<input><br>";
    echo "<a href='http://www.intermanch.blogfa.com'>view my weblog";
    //and all php cods even query from database 100% withod error
    }
    ?>
     
    <body>
    
    <input value='click me' type=button onclick="Helloo('200')">
    <div align=right  id=dl>
    </div>
    </body>
    </html>
    Last edited by intermanch; Jul 2 '10, 02:33 PM. Reason: complet
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    if you want to call PHP from JavaScript, you have to use AJAX (simply due to the fact, that PHP and standard JS have different execution times).

    but if there is no dynamic requirement, you can use PHP to create the appropriate JS code.

    Comment

    Working...