flemingmike Posted January 23, 2011 Share Posted January 23, 2011 hello. im trying to get the following to work. any ideas for me? Text[12]=["Job Description","$description it "] it is in a .js file. Link to comment https://forums.phpfreaks.com/topic/225378-adding-php-in-a-js-file/ Share on other sites More sharing options...
President Obama Posted January 23, 2011 Share Posted January 23, 2011 <?php echo $description; ?> ? That should work, shouldn't it? Link to comment https://forums.phpfreaks.com/topic/225378-adding-php-in-a-js-file/#findComment-1163877 Share on other sites More sharing options...
flemingmike Posted January 23, 2011 Author Share Posted January 23, 2011 i tried that. maybe im doing this a harder way that needed. what i have is a calendar that displays what i have to do. i want to be able to put my mouse over and have it show me a description in a small box. Link to comment https://forums.phpfreaks.com/topic/225378-adding-php-in-a-js-file/#findComment-1163880 Share on other sites More sharing options...
codefossa Posted January 23, 2011 Share Posted January 23, 2011 Why do you have PHP in a Javascript file? Just make a PHP file and include it in the page you wish to use the array. You can get your requested result by using the title attribute. Link to comment https://forums.phpfreaks.com/topic/225378-adding-php-in-a-js-file/#findComment-1163881 Share on other sites More sharing options...
flemingmike Posted January 23, 2011 Author Share Posted January 23, 2011 i tried the title way. the very first description started with i've. the ' isnt compatible with title. is there a way around this? Link to comment https://forums.phpfreaks.com/topic/225378-adding-php-in-a-js-file/#findComment-1163884 Share on other sites More sharing options...
codefossa Posted January 23, 2011 Share Posted January 23, 2011 i tried the title way. the very first description started with i've. the ' isnt compatible with title. is there a way around this? Don't use a ' to echo, and if needed use a \' or \" to wrap the attribute. Link to comment https://forums.phpfreaks.com/topic/225378-adding-php-in-a-js-file/#findComment-1163888 Share on other sites More sharing options...
flemingmike Posted January 23, 2011 Author Share Posted January 23, 2011 so if im echoing: echo "<a href='viewlog.php?id=".$id."' title='$description'><font color='#F70F02' size='3'>".$clientname."".$statusout."</font><font size='3' color='#ffffff'><br />".$starttime1." - ".$esttime1."</a><br />"; $description is what could have " or ' coming from mysql as well as possible other symbols. Link to comment https://forums.phpfreaks.com/topic/225378-adding-php-in-a-js-file/#findComment-1163889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.