Я не хочу ничего отправлять, просто отобразите значение, как калькулятор, который я искал вокруг, и я обнаружил, что могу сделать это, используя jquery, но число никогда не работает для меня (так что, если вы, ребята, можете порекомендуйте мне что-нибудь попроще). В последнем поле я хочу отобразить итоговое значение, умноженное на 27. В этом примере я пытаюсь умножить на 10 каждый раз, когда мы нажимаем на флажок, и в конце умножить итоговое значение на 27.
<div class="fields">
<div class="fields radio_label_top">
<fieldset>
<label> <input type="checkbox" name="sameAddress" value="freight" id="freight"> Freight $0.0</label>
<label> <input type="checkbox" name="sameAddress" value="insurance" id="insurance"> Insurance $0.00</label>
<label> <input type="checkbox" name="sameAddress" value="duty" id="duty"> Duty $0.00</label>
<label> <input type="checkbox" name="sameAddress" value="vat" id="vat"> VAT $0.00</label>
</fieldset>
</div>
</div>
<div class="fields ">
<div class="fields result">
<label>The fiels above show in USD currency</label>
<div class="dfield fields column2">
<input name="usdTotal" class="field large" type="text" value="1" id="usdTotal" placeholder='$ USD'>
</div>
</div>
This is my script
<script>
$(document).ready(function() {
$("#freight").click(function(){
if($(this).prop("checked") == true) {
$("#usdTotal").text(function(i, origText) {
localStorage['oldValue'] = origText;
return (+origText + ((origText * 10)));
});
} else{
$("#usdTotal").text(function(){
return localStorage.oldValue;
});
}
});
$("#insurance").click(function(){
if($(this).prop("checked") == true) {
$("#usdTotal").text(function(i, origText) {
localStorage['oldValue'] = origText;
return (+origText + ((origText * 10)));
});
} else{
$("#usdTotal").text(function(){
return localStorage.oldValue;
});
}
});
$("#duty").click(function(){
if($(this).prop("checked") == true) {
$("#usdTotal").text(function(i, origText) {
localStorage['oldValue'] = origText;
return (+origText + ((origText * 10)));
});
} else{
$("#usdTotal").text(function(){
return localStorage.oldValue;
});
}
});
$("#vat").click(function() {
if($(this).prop("checked") == true) {
$("#usdTotal").text(function(i, origText) {
localStorage.oldValue = origText;
return (+origText + ((origText * 10)));
});
} else{
$("#usdTotal").text(function() {
return localStorage.oldValue;
});
}
});
$("#usdTotal").change(function() {
$("#ttdTotal").text(function(i, origText) {
return (+origText * 27 );
});
});
});
</script>