Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript PHP
Hi all i have a small bit of code
 
<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 21-Nov-12 17:57pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 22-Nov-12 1:57am
   
your comment deserve a 5
Sergey Alexandrovich Kryukov at 22-Nov-12 2:09am
   
Thank you, Mohibur.
--SA
Rai Pawan at 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 at 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)

  Print Answers RSS
0 OriginalGriff 349
1 Nirav Prabtani 268
2 Richard Deeming 215
3 CHill60 170
4 _Amy 145
0 OriginalGriff 8,104
1 Sergey Alexandrovich Kryukov 7,045
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100