Click here to Skip to main content
15,894,291 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi all i have a small bit of code

JavaScript
<script>
function fun(var1_name)//var1_name is the name of the button which is clicked from html table
{
var s="t"+var1_name;
var x=document.getElementById(s).value;

}
</script>



What i need is i have to pass the x variable to a PHP function which have some logic. How to pass x to the php fuction?. Pls help
Posted

1 solution

There is no way to directly pass the values of client script variable to server side variables/functions, Since both these scripts execute on different platforms i.e., client browser and web server respectively. The only way is to use AJAX to do it. So I'd recommend you to read AJAX tutorials

Regards
Pawan
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Nov-12 1:35am    
Agreed, a 5.
For a note: "the only way" needs some explanation: "the only way" of what? It cannot be called a call, this is HTTP request. I understand what you mean, but OP may need some clarification. It's not that Ajax specifically should be understood, but rather how Web works and what happens on the server and client parts...
--SA
Mohibur Rashid 22-Nov-12 1:57am    
your comment deserve a 5
Sergey Alexandrovich Kryukov 22-Nov-12 2:09am    
Thank you, Mohibur.
--SA
Rai Pawan 22-Nov-12 2:14am    
Thank you Sergey for your comments and ranking. Indeed, underlying concepts of how web works and how the interaction between client and server happens should be understood.
--regards Pawan
Sergey Alexandrovich Kryukov 22-Nov-12 2:42am    
Sure.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900