Start New Discussion Reply to this Discussion How to increment php array variable inside javascript...
Hi everyone
$i=0;
echo '<script language="javascript">
var dA = new Array();
var x = 0;
for(i=0;i<2;i++)
{
dA[x++]="'.$date[$i]." ".$message[$i].'";
'.$i++.';
}
</script>';
here i want to increment $i above code is not working, Please help...Thanks in Advance...
Related Article: Passing PHP variable to javascript
is a solved JavaScript / DHTML / AJAX discussion thread by Drako12 that has 6 replies and was last updated 2 years ago.
druveen
Newbie Poster
10 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
You can't execute a client side(javascript) for loop on the server side(php). You can print javascript out incrementally that would be an array of size 2 using a for loop on your server side. For instance:
$i = 0;
echo '<script type=text/javascript>';
echo 'var dA = new Array();';
for ($i = 0; $i < 2; $i++)
{
echo 'dA['.$i.'] = "'.$date[$i].$message[$i].'";';
}
echo '</script>';
scrappedcola
Posting Whiz in Training
227 posts since Dec 2009
Reputation Points: 27
Solved Threads: 45
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.2830 seconds
using 2.65MB