Passing PHP variable outside PHP OOP class (from separate PHP file) onto node value of a HTML tag in a JQuery function -
Passing PHP variable outside PHP OOP class (from separate PHP file) onto node value of a HTML <span> tag in a JQuery function -
it possible pass reference in php variable taken within scope of instantiated object class (php) jquery function, in order render number or string display number of items added? have code here this:
<!--in cart.php--> $(document).ready(function() { $('div#cart').replacewith('<div id=\'cart2\'><span><?php echo ('.**$itemcount**.'); ?> </span> <a href=\'viewcart.html\' class=\'view-cart\'>view cart</a><a class=\'checkout\' href=\'checkout.html\'>checkout</a></div>'); }); where $itemcount stored variable in php external file called store.php
many assistance!
an interesting question least...
lets store.php looks this:
<?php class store { private $_itemcount = 0; public function getitemcount(){ homecoming $this->_itemcount; } } ?> from there go in cart.php:
<?php $store = new store(); $itemcount = $store->getitemcount(); echo <<<html $(document).ready(function() { $('div#cart').replacewith("<div id='cart2'><span>$itemcount</span><a href='viewcart.html' class='view-cart'>view cart</a><a class='checkout' href='checkout.html'>checkout</a></div>"); }); html; ?> this way, can homecoming value , utilize in javascript.
php jquery reference scope
Comments
Post a Comment