0
I am getting error Uncaught SyntaxError: Unexpected identifier
on line : TableX[i] = <?php echo $TableX[$x];  ?> ;
In the code below :
 index.php

for( i = 1 ; i<= <?php echo $num;?> ; i++) 
        {
            <?php for($x = 1 ; $x<=$num ; $x++ ) { ?>
            TableX[i] = <?php echo $TableX[$x];  ?> ;
            TableY[i] = <?php echo $TableY[$x];  ?> ;
        }
        <?php } ?>

I've wasted enough time on this , help would be really appreciated .

1
  • Are you getting that syntax error from PHP (at the server) or JS (on the browser console)? If the latter, is PHP enabled at all? Commented Jan 25, 2015 at 22:03

1 Answer 1

1

You can just output a php array as JSON:

<script>
var TableX = <?php echo json_encode($TableX);?>
Sign up to request clarification or add additional context in comments.

1 Comment

var TableX = <?php echo json_encode($TableX);?> ; var TableY=<?php echo json_encode($TableY);?> ; for(i = 1 ; i <= <?php echo $num ;?>; i++) {divToAdd = $("<div></div>"); $(divToAdd).addClass('dragged1'); $(divToAdd).offset({ left:TableX[i] , top:TableY[i]}) ; $('#frame').append(divToAdd); } It looks like there is syntax error in offset() , since when I run it , it does not take values rather it treats it as a text . guide me with this ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.