How to call Javascript function in PHP?

Let’s learn how to call Javascript function in PHP. The most accurate or helpful solution is served by Stack Overflow.

There are ten answers to this question.

Best solution

php, how to call a javascript function?

i am trying to use gigya auth properties to login users on my website. They have a function that needs to be called after i authenticate the credentials as seen in this illustration I have a form and when i submit the form i send it to login.php where i authenticate my users. My question is how do i call socialize.notifyLogin?. this is the javascript: <script type="text/javascript"> var conf = { APIKey:'2_9E9r_ojXEqzZJqKk7mRqvs81LtiSvUmBcm' }; </script> <script type=...


You have two options: If you call login.php as the target of an HTML form, you should redirect the user...

Read more

Patrioticcow at Stack Overflow Mark as irrelevant Undo

Other solutions

How can I mix javascript and php? With one button I want it to call a php function as well as a javascript function?

I am really struggling with this. If I use a submit button and then say: <?php if isset($_POST['buttonName']){ ?> call some javascript function. <?php } ?> The above code does not work properly. if do an onclick for the submit button...


I would like you to go through Browser — Server Communication good discussion on this. What...

Read more

Ashish Kasama at Quora Mark as irrelevant Undo

I have a JavaScript function from which I need to call a PHP function written in a separate file. How can I do this?

The PHP function returns a value that I want to assign to a JavaScript variable.


Assuming you can modify the code in both files: Turn the PHP function into a web service which accepts...

Read more

Bulat Bochkariov at Quora Mark as irrelevant Undo


Hi mani! U cant call a php function from a javascript. Javascript is a client side scripting language...

Read more

Mani at Yahoo! Answers Mark as irrelevant Undo

I want to call a function written in .cs code file in a .js (javascript). How to do this?   (There a way to call this cs function through Ajax call but dont have much idea about the same.)

For example there is a class  Sample.cs public class Test {  publiv void TestFunction()  {   // set of code  } } the TestFunction is to be called in the javascript function <script type="C#/javascript"> function TestCall() {  Test.TestFunction...


It really depends that which technology stack are you in. I have background so I will answer...

Read more

Muhammad Haseeb Asif at Quora Mark as irrelevant Undo

How do I call a plugin function inside a PHP template for WP sites?

I am using a pagination plugin in my WP site. As pagination works, it  must be laid inside an index.php file, else it will not show the output.  But i wish to call the same function in a template file. I have the php  code but when I call that function...


Just  a simple suggestion that instead of making multiple copies of same  function, why not create a...

Read more

Rahul Balakrishna at Quora Mark as irrelevant Undo

WordPress Theme Development: How can I trigger a JavaScript function when a particular widget's save button is pressed in widgets.php in the admin area?

This almost works but the alert won't fire on the first click on the Save button. It does after the second click however. So I'm looking for a way that is more reliable. class My_Widget extends WP_Widget { function __construct() { parent::__construct...


Try .on("click", "", fn); vs. .click() which looks in the live DOM (widgets...

Read more

Nick Ciske at Quora Mark as irrelevant Undo

How can I call a Function in another php file? I'm pretty new in PHP.?

I have this codes: /*my another php file*/ <?php myfunction(param1,param2){ /-----/ return myresult; } ?> Now, how i call it from my main php page,a nd get the result of my function?


<?php require("mainfile.php"); function myfunction($param1, $param2) { return mainfilesfunction...

Read more

jay at Yahoo! Answers Mark as irrelevant Undo

When I call a Java applet function by reference from JavaScript code, it doesn't work correctly.   Is it possible to call Java functions by reference from JavaScript? My guess: I think because Java takes memory on JVM, it is not possible.

// Java Code:     public class  A extends Applet{             public void foo(int[] a)         {             a[0]=3;         }     }         //Javascript Code:     var arg = new Array(1);     arg[0]=2;; But `arg[0]` remains `2`


You are right, JavaScript arrays are copied and converted before they are passed to Java Code. From...

Read more

David Tanzer at Quora Mark as irrelevant Undo

PHP how to use echo and then call a function?

How to make an echo to call a function example : <?php ob_start(); session_start(); $applications=getApplication($_SESSION… $count=mysql_numrows($applications); if($count==0) { echo "You dont have any applications submited"; } else...


If I understood your problem correctly, you need to do it the same way you used nl2br in echo statement...

Read more

Alvin at Yahoo! Answers Mark as irrelevant Undo

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.