You have to understand one thing… the PHP code is evaluated at the moment when this code is rendered… JS code is evaluatd at the client at the moment that this function is executed… so even if there would be a way… it wouldnot work like you would like it becasue PHP is run before the JS code and at that time the JS variable has no value (in fact it does not exist yet)…