Car Insurance - Credit Card - Online Advertising - Turbo Tax - Agencia de turismo

PDA

View Full Version : Using Javascript and PHP


vijaykoul
Feb 8th 2005, 6:06 am
Hi everybody,

I want a value calculated in Javascript to be used in PHP b'coz that value
will act as an argument for the function defined in PHP. Can I do it

If yes, how?

One thing I want to tell is that that function is to be defined in PHP only and not i Javascript.

In short can I use a value calculated variable of Javascript in PHP.

It is urgent...
Need help.

Thanx
VJ

digitalpoint
Feb 8th 2005, 7:47 am
Not directly... JavaScript is client-side and PHP is server-side. The best you would be able to do is calculate whatever you want to calculate in JavaScript, then have the JavaScript trigger the loading of a page with that value within the URL (or a field in a form post) so PHP could evaluate it.

Josh
Feb 8th 2005, 9:02 am
Yes, the way Shawn just mentioned is about the only way to do it.

i.e. have the javascript do a window.location = 'file.php?varible=thevar' and have the PHP file use $_GET['varible'] to get it..


Josh

vijaykoul
Feb 9th 2005, 2:32 am
the problem now is that all the values i have calculated in Javascript have to be passed to a Payment gateway file and hence i dont think i wil be able to $_GET them.

any other alternative

dtan
Mar 12th 2005, 7:37 am
couldn't you write a wrapper file that would simply retrieve the get or post value and then call or include the necessary file?