gpt4 book ai didi

javascript - 计算器在其他浏览器中不工作

转载 作者:行者123 更新时间:2023-11-29 17:57:57 25 4
gpt4 key购买 nike

我有一个在 chrome 中运行良好但在其他浏览器(edge、firefox、explorer、opera)中运行良好的计算器功能。谁能告诉我哪里出了问题。谢谢

<div class="content ticket_wrapper">
<div class="table">
<div class="row header">
<div class="cell">Ticket</div>
<div class="cell"><div class="align"> Price</div></div>
<div class="cell"><div class="align"> Qnty</div></div>
<div class="cell">Total</div>
</div>
<div class="row">
<div class="cell">Normal</div>
<div class="cell"><div class="align"> KSH 650</div></div>
<div class="cell">
<div class="ticket">
<select oninput="calculate()" id="titotal" class="titotal">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div>
<div class="cell">
<span id="result"></span>
</div>
</div>
<div class="row">
<div class="cell">Advanced</div>
<div class="cell"><div class="align"> KSH 950</div></div>
<div class="cell">
<div class="ticket">
<select oninput="calculate()" id="titotal_2" class="titotal">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div>
<div class="cell">
<span id="result2"></span>
</div>
</div>
</div>
<div class="table_tots">
<div class="row grand_total">
<div class="cell">
Sub Total :
<span id="grand_total"></span>
</div>
</div>
</div>
<div id="sub">
<input class="submit" type="button" value="Proceed">
</div>
</div>

$('#sub').hide();
$('.titotal').on('click', function(event){
var one = $('#titotal').val();
var two = $('#titotal_2').val();
if (one>0 || two>0) {
$('#sub').show();
}else{
$('#sub').hide();
}
});

function calculate(){
var mybox1 = document.getElementById('titotal').value;
var mybox2 = document.getElementById('titotal_2').value;
var myresult = mybox1 * 650;
var myresult2 = mybox2 * 950;
var total = myresult + myresult2;
document.getElementById("result").innerHTML = myresult;
document.getElementById("result2").innerHTML = myresult2;
document.getElementById("grand_total").innerHTML = total;
}
window.onload = calculate();

我正在为购票网站构建一个表

最佳答案

至少对于FireFox来说,改一下就够了:

<select oninput="calculate()" id="titotal" class="titotal">

收件人:

<select onchange="calculate()" id="titotal" class="titotal">

而且它有效。那时甚至不需要按钮。

关于javascript - 计算器在其他浏览器中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37431442/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com