这是在HTML我的功能的onClick脚本,它完美的作品:的JavaScript里面的PHP代码回声
<input type="text" id="t" name="t" value="1">
<a href="testar.php?action=" onclick="window.location=this.href+'&quant='+document.getElementById('t').value;return false;">Click</a>
什么,我想实现的是:
echo '<input type="text" value="1" id="t" name=""/>
<a href="addCarrinho.php?id_produto='.$registo['id'].'&nome='.$registo['nome'].'&preco='.$registo['preco'].'" onclick="window.location=this.href+'&quant='+document.getElementById('t').value;return false;">Add</a>';
所有的PHP的作品,我收到php变量在另一页上,但onClick的JavaScript脚本不工作,即时获取sintaxe错误。 我认为它是一个引号问题,但我不熟悉javaScript。
在你的问题中的语法高亮显示你的问题 - 使用反斜杠逃脱单引号那里 –