View Full Version : How to use a Javascript variable in PHP

11-06-2007, 12:48 AM
I'm trying to use a JS variable from a chained menu script that I found to populate a variable in a PHP RSS script that I have? Unfortunatley I'm not very expierienced in JS, and am just learning PHP the JS code looks like this:

function goListGroup(){
for (i=arguments.length-1;i>=0; i--){
if (arguments[i].selectedIndex!=-1){
var selectedOptionvalue=arguments[i].options[arguments[i].selectedIndex].value
if (selectedOptionvalue!=""){
if (onclickaction=="alert")
else if (newwindow==1)

The final variable 'selectedOptionvalue' in its original form opened a URL, but what I'm hoping to do is to assing that value to a variable in my config.php file. That line looks like this:

$keyword = "my very own keyword";

I know that JS is client side and php is server side, so I'm not sure how to 'merge' the to codes

Thanks in advance for your help

11-06-2007, 04:38 AM
I have the same problem (i think)
Trying to pass a javascript value to php:
use ajax

for using a php value in javascript, just use

...js codes...
var phpVar = "<?php echo $myvar ?>";

Or something like that. you get the point...im not too great with php