Hi, I have a javascript timer which runs from x seconds till 0, what I want to do is set the starting value set from an IF statement, how can this be done?
Something like this? <html> <body> <script lang="javascript"> <? if($thing){ $yourPhpVariable = 50; }else{ $yourPhpVariable = 10; } echo "var PHPVar = " . $yourPhpVariable; ?> if(PHPVar){ alert(1); } </script> </body> </html> Code (markup): Something along those lines?
if you want to interactively pass php data into a page (of any type) without it reloading, you'll need to use ajax style requests. If your passing it though just once, it seems fine.
The data just needs to be passed once, per page load. ToddMicheau, that is exactly what Im looking for, could you explain the part below, as to what it means? if(PHPVar){ alert(1); Code (markup):
I just included that piece of code so you could tell if the variable has a value or not (If the variable is anything but 0 the IF statement will return true and run the block), you can erase that and put in your own code. =]