日期:2014-05-17  浏览次数:20396 次

PHP echo了一个按钮,但是触发不了click事件

<?php 
echo '<input name="minus"  type="button" value="-" onclick="num_minus("xx");"/>';
echo '<input name="num" id="xx" type="text" width="16" value="1"'.'>';
echo '<input name="plus" type="button" value="+" onclick="num_plus("xx");"/>';
?>
<script type="text/javascript">
function num_plus(id_num)
{
document.getElementById(id_num).value++;
//document.getElementById('num').value=parseInt(document.getElementById('num').value)+1;
        //parseInt(a,b)将a解析成b进制数
}
function num_minus(id_num)
{
if(document.getElementById(id_num).value==1)
document.getElementById(id_num).value=1;
else
    document.getElementById(id_num).value--;
}
</script>

PHP 按钮 click

------解决方案--------------------
你用的引号很混乱……理清再说
------解决方案--------------------
echo '<input name="minus"  type="button" value="-" onclick="num_minus(\'xx\');"/>';
echo '<input name="num" id="xx" type="text" width="16" value="1"'.'>';
echo '<input name="plus" type="button" value="+" onclick="num_plus(\'xx\');"/>';


onclick="num_minus("xx");" 在浏览器中要报错的!