d.shankar Posted November 7, 2007 Share Posted November 7, 2007 I am unable to pass my php parameter to the javascript. But it is not getting fetched. <?php $str="from php"; ?> <script> var abc="<?php echo($str) ?>" alert(abc); </script> <?php ?> Link to comment https://forums.phpfreaks.com/topic/76356-solved-parameter-passing/ Share on other sites More sharing options...
ToonMariner Posted November 7, 2007 Share Posted November 7, 2007 perhaps maybe use this <script type="text/javascript"> ????? Link to comment https://forums.phpfreaks.com/topic/76356-solved-parameter-passing/#findComment-386589 Share on other sites More sharing options...
NArc0t1c Posted November 7, 2007 Share Posted November 7, 2007 Try: <?php $str = "from php"; ?> <script> abc = "<?=$str?>" alert(abc); </script> <?php //other code ?> Link to comment https://forums.phpfreaks.com/topic/76356-solved-parameter-passing/#findComment-386594 Share on other sites More sharing options...
rajivgonsalves Posted November 7, 2007 Share Posted November 7, 2007 you missed out the semi-colin <?php $str="from php"; ?> <script> var abc="<?php echo($str) ?>"; alert(abc); </script> <?php ?> Link to comment https://forums.phpfreaks.com/topic/76356-solved-parameter-passing/#findComment-386604 Share on other sites More sharing options...
NArc0t1c Posted November 7, 2007 Share Posted November 7, 2007 you missed out the semi-colin <?php $str="from php"; ?> <script> var abc="<?php echo($str) ?>"; alert(abc); </script> <?php ?> Many programmers continue this habit when writing JavaScript, but in general, semicolons are optional! However, semicolons are required if you want to put more than one statement on a single line. Link to comment https://forums.phpfreaks.com/topic/76356-solved-parameter-passing/#findComment-386607 Share on other sites More sharing options...
d.shankar Posted November 7, 2007 Author Share Posted November 7, 2007 Thanks a lot guys ! Semicolons are not neccesary in JS. Link to comment https://forums.phpfreaks.com/topic/76356-solved-parameter-passing/#findComment-386611 Share on other sites More sharing options...
ToonMariner Posted November 7, 2007 Share Posted November 7, 2007 In php!!! <script type="text/javascript"> var abc="<?php echo($str); ?>"; alert(abc); </script> Link to comment https://forums.phpfreaks.com/topic/76356-solved-parameter-passing/#findComment-386666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.