嗨我正在为网上商店的uni网站工作。 我使用NOP设计freecart和一切工作正常。将javascript添加到php标题
我在PHP中的菜单和报头正常工作,但我不能让我的JavaScript它显示在购物车和总项目在PHP菜单
PHP头
<h1 id="logo"><a href="index.html">Pet Accessories</a></h1>
<!-- Cart -->
<div id="cart">
<a href="managecart.html" class="cart-link" >Your Shopping Cart</a>
<br>
</div>
<!-- End Cart -->
<!-- Navigation -->
<div id="navigation">
<ul>
<li><a href="index.html" class="active">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<!-- End Navigation -->
JavaScript的我要使用
scart.js文件
if (Cart_is_empty()) {
document.write('Your cart is empty.');
} else {
document.write('In your cart:<p>');
Print_total_products(true);
document.write(', ');
Print_total(true);
document.write('<p>Applicable shipping and taxes extra.<p>');
document.write('<a href="managecart.html">View Cart</a>');
}
如果我粘贴代码到我的index.html文件是正确显示,但是当我将其粘贴到PHP文件它不工作
我试过粘贴在此 <?php echo "<script type=\"text/javascript\" src=\"/js/scart.js\"></script>; ?>))
到header.php
文件,但也不起作用。
关于我应该做什么的任何想法?我从一个网站上使用的购物车代码,因此对于我来说很难理解。
任何帮助,将不胜感激,谢谢
建议:忽略他们在uni教你的东西,而是拿起一本关于JS的好书和/或访问这样的网站,在那里你可以学习使用适当的技术进行编码。 ;) –
为什么在php标签中包含它,如果它只是一个模板文件? –
向我们展示输出的标题部分,其中jscript文件应该是 – bouscher