-2

i want to call php function inside javascript like this. i want value inside array r can be added to my_func() as parameter. but i get an error when do this.

for(i=0;i<r.length;i++){
    var distance = <?php echo my_func(+r[i].coordinate+);?>;
}

or

for(i=0;i<r.length;i++){
    var distance = <?php echo my_func(?>r[i].coordinate<?php );?>;
}

If any one have an idea to help I really appreciate it because I need it so much, and thanks to all.

Muhammad Rauuf
  • 104
  • 1
  • 14

1 Answers1

0

Generally a bad idea to mix php and javascript like that. Either grab the values you need with ajax or print out them out into the html and then grab them with javascript.