Click here to Skip to main content
13,096,660 members (84,300 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all i have a small bit of code

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;

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
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

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...
Mohibur Rashid 22-Nov-12 1:57am
your comment deserve a 5
Thank you, Mohibur.
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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170813.1 | Last Updated 22 Nov 2012
Copyright © CodeProject, 1999-2017
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