By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,569 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,569 IT Pros & Developers. It's quick & easy.

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

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

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. <!--
  4. this code only call funnctions php but
  5. how call function php[ function-name(varible)]
  6. intermanch@gmail.com
  7. www.intermanch.blogfa.com
  8. -->
  9.  
  10. <script>
  11. function Helloo($f)
  12. {
  13. var t4 = document.createElement('div');
  14. t4.innerHTML ="<?php hello() ?>";
  15. document.getElementById('dl').appendChild(t4);
  16. }
  17. </script>
  18.  
  19. <?php
  20. function hello()
  21. {
  22. //if on the java script can write function-name(varible) than can write echo varible;
  23. //echo $x;
  24. //help to complet this code
  25. echo "name: ";
  26. echo "<input><br>";
  27. echo "<a href='http://www.intermanch.blogfa.com'>view my weblog";
  28. //and all php cods even query from database 100% withod error
  29. }
  30. ?>
  31.  
  32. <body>
  33.  
  34. <input value='click me' type=button onclick="Helloo('200')">
  35. <div align=right  id=dl>
  36. </div>
  37. </body>
  38. </html> 
  39.  
Jul 2 '10 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
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.
Jul 5 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.