last day (14 days later) » 

4:44 PM
0
A: get value using php to javascript code

NicolasWhen you load your Javascript, If it's in a HTML compatible with PHP ( ends with .php ) you can simply echo your value in a string. Html <body> <!-- ... --> <script> /*...*/ var value = "<?php echo $variable; ?>"; /*...*/ </script> <!-- ... --> </body>...

 
dear thanks for your answer but like i said i only want to get value from WHATEVER IS IN HERE to GRAB IT HERE
 
well you can simply do "item": "<?php echo $filename ?>".
 
i did like this "@id": "http://domain.com.com/foldera/folderb/file.php", "name": "<?php echo $filename ?>" i get empty when i checked source code like this "name": ""
 
Have you checked if your variable $filename is not empty ?
 
if you mean here on my php $filename => 'HERE' it's not empty but i think it's not as "variable" is it ?
can you dear check my whole php code above ? i don't have $filename anywhere else on my page
 
4:45 PM
Yea i just got that, Actually you need to call $Pages[$filename] sorry my bad.
Hey, the variable $filename is the variable you get from exploding your file.
 
thank you so much Nicole
Nicolas*
i will try your last comment
 
ok let me know if it works.
 
like this "name": "<?php echo $Pages[$filename]; ?>"
i still get empty
 
try to do a die(var_dump($Pages[$filename])) in your PHP, this will show you what's in your variable. Don't worry about your page not showing tho, the code stop after the die() just remove it once your done.
And check if there is something where the $filename position is in your array.
 
Filestring(3) "File"
i get that
where "File" is value
 
4:51 PM
Hum, that's weird.
It should echo properly into your Javascript.
 
what i am thinking is maybe...
javascript loads first
thats why it doesn't get the value
or i am wrong ?
 
no it's impossible since your PHP is loading your HTML and your JavaScript is in your HTML.
 
because javascript code is in head
 
is it in the same page where you set your $Pages array ?
 
yeah
all of them in same page
 
4:55 PM
If you just put this in your HTML <span><?php var_dump($Pages) ?></span>, do you see the value you want in the array ?
 
i did put that right after body, i got "NULL"
 
that's why you can't get your value, the array is null.
I don't know why tho.
 
did you check my php code nicolas ?
i don't know what is empty
$Pages = array(
'foldera' => 'foldera',
'folderb' => 'folderb',
$filename => 'WHATEVER IS IN HERE'
);
this should be the value "HATEVER IS IN HERE"
 
Yea i know, I did check you PHP code and i can't see why it's null when you load your HTML
Sorry i can't help you more then that, YOu can use var_dump to check the value of your variable through your code, which can be handy but further than that i have no idea.
 
it's ok Nicolas
thanks for being kind
 
5:03 PM
No problem, Good luck with your problem
 
one question nicolas
i need help sometimes in stuff like this like editing and something is wrong etc. how can i reach you if i can ?
 

last day (14 days later) »