Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing Javascript variable to PHP variable

Status
Not open for further replies.

iandobrien

Programmer
May 2, 2002
7
IE
Ok, sorry to be bothering you all again but here's the problem. I have a javascript variable and i want compare this to a PHP variable so what i want to do is store it in a PHP variable so i can do the comparisons (i really need to store it in a PHP variable rather than the other way round ie. i don't want to store the PHP variable in a javascript variable)Anyone got any bright ideas???
 
i've never used php, but i'm going to asume it's like asp. try this:

document.location.href = document.location.href + "?varname="+js_var_name;
 
sorry if i confused some people...what i meant was the following..

Say i have a PHP variable called '$string'. I then wanted to compare this to a javascript variable (say using an 'if' condition). So, for example take the javascript variable to be called 'X'. So what i want to do is compare them ie.

<?php
if($string == X)
{
.............etc etc.
}?>

This obviously doesn't work so i thought something like....

<?php
if($string ==<SCRIPT LANGUAGE = 'JavaScript'>X</SCRIPT>)
{
.............etc etc.
}?>

but that didn't work either..anyway, i'm a little confused as to some of the suggestions given above but much appreciated anyway...maybe its a little clearer now??cheers,Ian

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top