Use a javascript variable in the PHP Code -
i want use value of 'n1' variable in 5 , 6 lines off code. means 'n1' variable javascript variable , want use in following php code lines:
var x=50*math.cos((<?php echo posst($streamval[n1][1]); ?>*math.pi)/50)+100; var y=50*math.sin((<?php echo posst($streamval[n1][1]); ?>*math.pi)/50)+75; <script> (var n1 = 0; n1 <= 3; n1++) { ctx.beginpath(); ctx.moveto(100,75); var x=50*math.cos((<?php echo posst($streamval[n1][1]); ?>*math.pi)/50)+100; var y=50*math.sin((<?php echo posst($streamval[n1][1]); ?>*math.pi)/50)+75; ctx.lineto(x,y); x=quarterx(x,y,<?php echo posst($streamval[0][1]); ?>); y=quartery(x,y,<?php echo posst($streamval[0][1]); ?>); ctx.font = "10px arial"; ctx.stroketext('<?php echo posst($streamval[0][0]); ?>',x,y); } </script>
how can that? thanks.
you dont use javascript variable in php, can create loop in php
<script> <?php ($n1=0;$n1<=3;$n1++){ ?> ctx.beginpath(); ctx.moveto(100,75); var x=50*math.cos((<?php echo posst($streamval[$n1][1]); ?>*math.pi)/50)+100; var y=50*math.sin((<?php echo posst($streamval[$n1][1]); ?>*math.pi)/50)+75; ctx.lineto(x,y); x=quarterx(x,y,<?php echo posst($streamval[0][1]); ?>); y=quartery(x,y,<?php echo posst($streamval[0][1]); ?>); ctx.font = "10px arial"; ctx.stroketext('<?php echo posst($streamval[0][0]); ?>',x,y); <?php } ?> </script>
it works?
Comments
Post a Comment