<!doctype html>
<?php
//First write the relevant calling code here
$coin = 1280;
$money = 1121;
$coinsale = $coin / 100;
if ( $_POST[ "coin" ] != 0 ) {
$money -= $coinsale;
}
?>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form id="form1" name="form1" action="test.php" method="post">
<input id="coin" name="coin" type="checkbox" value="<?php echo($coinsale)?>" onclick="checkboxOnclick(this)">Tuotecoin
<input id="sale" type="hidden" value="<?php echo($money)?>">
<input id="asd" type="hidden" value="<?php echo($coinsale)?>">
<p id="npay" style="width:100%;height:95px;line-height:50px;font-weight:800;font-size:14px;color:red; text-align:center">
¥
<?php echo $money; ?>
</p>
<input type="hidden" id="goodsmoney" name="goodsmoney" value="<?php echo $money; ?>"/>
</form>
</body>
<script>
function checkboxOnclick( checkbox ) {
var goods = document.getElementById( "npay" );
var m = document.getElementById( "sale" ).value;
var c = document.getElementById( "asd" ).value;
var f = document.getElementById( "form1" );
if (checkbox.checked == true) {
m -= c;
goods.innerHTML = "¥" + m;
f.submit();
} else {
goods.innerHTML = "¥" + m;
}
}
<!--$.("input[type='checkbox']:checked")-->
</script>
</html>
I hope you can give me a small example. I don’t know the specific implementation and I’m not familiar with PHP. Thank you everyone:)
After submitting the form, you can get the value in the controller and pass it back
Fixed location storage, eg: Add a hidden tag to the page to store the selected value, cookie
Do not refresh the page, use ajax to pass the value
Put an iframe on the page, copy the form to the iframe, and submit it
$.("input[type='checkbox']:checked") After getting the value, you can put it in the cookie. Every time you refresh the page, first get the value in the cookie, and then use .each to loop through the effect. Come out