I am trying to dynamically create variables in javascript
. In my PHP
code I already dynamically create variables from SQL
output which gives me $res1
, $res2
, etc. Now I want to use these in my javascript
but of course I cannot hardcode it for I can never know how many of the $res
variables the PHP
will generate.
I have the feeling I am already fairly close though. I have the following:
var i=1;
while (i<=count) {
var name = "<?php ${"res".$_GET['i']} ?>";
}
Sebcap26, it is indeed related to passing variables from php to javascript but as you probably see my problem is passing variables + combining javascript and php variables to create a javascript variable. – logos Aug 26 '14 at 07:02