Incrementing a php variable in javascript
Posted: Sun Oct 12, 2003 7:26 am
Hi,
I am in need of a fix... I'm am running mainly PHP but in some cases need to have javascript for manipulation of client side data. The problem i'm having is the following:
When a page gets loaded i'm building PHP arrays. These arrays and variables are global. Depending on what the user selects, I am searching through the PHP array. The problem is that I can't seem to increment a PHP variable within the javascript code. The following code shows the problem..... here I am trying to increment $GLOBALINC as I use it as an index in the array.
function blah()
{
var cnt = <?=$cnt ?>;
var ind = 0;
var rr = "";
while(ind < cnt)
{
<?php
if($cnt > 1)
{
?>
rr = '<?= $rrconfig[$GLOBALINC][0] ?>';
<?php
$GLOBALINC++;
}
?>
ind++;
}
Any ideas why the increment won't happen?
Thanks.
I am in need of a fix... I'm am running mainly PHP but in some cases need to have javascript for manipulation of client side data. The problem i'm having is the following:
When a page gets loaded i'm building PHP arrays. These arrays and variables are global. Depending on what the user selects, I am searching through the PHP array. The problem is that I can't seem to increment a PHP variable within the javascript code. The following code shows the problem..... here I am trying to increment $GLOBALINC as I use it as an index in the array.
function blah()
{
var cnt = <?=$cnt ?>;
var ind = 0;
var rr = "";
while(ind < cnt)
{
<?php
if($cnt > 1)
{
?>
rr = '<?= $rrconfig[$GLOBALINC][0] ?>';
<?php
$GLOBALINC++;
}
?>
ind++;
}
Any ideas why the increment won't happen?
Thanks.