日期:2014-05-17 浏览次数:20425 次
<?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>
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\');"/>';