<?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>
This can only change the text of the Txt text box, but cannot actually change the PHP output value
I tried putting the CheckBox in the form submission and gave my own PHP judgment, but I didn't get it
I would like to ask you how to do it Thank you for this
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.