<?php
$coin=1280;
$money=1121;
$coinsale=$coin/100;
?>
<input id="money" type="hidden" value="<?php echo $money?>">
<input id="coin" type="checkbox" value="<?php echo $coinsale?>" onclick="checkboxOnclick(this)">asdsa<br>
<input id="salemoney" type="txt" style="border: none" readonly="true" ><?php echo $money?>
</body>
<script type="text/javascript">
function checkboxOnclick(checkbox) {
var num1=document.getElementById("money").value;
var num2=document.getElementById("coin").value;
var num3=num1-num2;
if ( checkbox.checked == true){
document.getElementById("salemoney").value=num3;
}else{
document.getElementById("salemoney").value=num1;
}
}
</script>
这个只能更改Txt文本框的文本,不能实际改变php输出值
尝试过将将CheckBox放在表单提交 ,给 自己php判断,但是没有获取到
想请问下大家如何做这个谢谢哒
Just write an ajax interface in the background.
ajax I won’t write it, if you don’t know how to Google it yourself.
Personally, if you want to change the output value here, it is more appropriate to use js to handle it.