Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Priscilla Kam
1,086 Pointsphp and jquery/javascript issues
hi everybody
how can i transfer php values to jquery code in a php page so that php values can be use in those js code
e.g. php => $rows['name'];
jquery =>
<script type="text/javascript"> $(function(){ cart.addBuyButton("#macbook",{ id:'item_1', // Specify the unique id for this item name:' NAME OF THE PHP CODE ', // Item name appear on the cart thumbnail:'product_thumbnail.jpg', // Thumbnail path of the item (Optional) price:10, // Cost of the item shipping:5 // Shipping cost for the item (Optional) }); }); </script>
2 Answers
Randy Hoyt
Treehouse Guest TeacherTry something like this:
<script>
var flavor = "<?php echo $flavor; ?>";
</script>
Does that help?
Priscilla Kam
1,086 Pointsyes it help