gpt4 book ai didi

javascript - 添加下拉列表和复选框值

转载 作者:行者123 更新时间:2023-11-30 17:59:43 24 4
gpt4 key购买 nike

我正在尝试从 和 复选框中获取值,并将值放入文本框中,或者如果两者都被选中,则添加下拉列表和复选框并将其放入文本框中。代码中有一个 JavaScript 错误,您可以在下面的链接中看到,在 IE 中,但它在 Chrome 中可以正常工作。对此有何指导?

function TotAmt() {
var DA = +document.getElementById("Donation").options[Donation.selectedIndex].value;
if (document.form1.somename.checked == true) {
document.form1.Summary.value = parseInt(DA) + parseInt(500);
} else {
document.form1.Summary.value = parseInt(DA);
}
}

View sample code

最佳答案

通过不将 javascript 包装在头部,您可以消除 jsFiddle 中的特定错误。然后在 ToAtm() 函数中使用 getElementById 函数,如下所示:

function fnchecked(blnchecked) {
if (blnchecked) {
document.getElementById("CoatSizeDiv").style.display = "";
} else {
document.getElementById("CoatSizeDiv").style.display = "none";
}
}

function TotAmt() {
var DA = +document.getElementById("Donation").options[Donation.selectedIndex].value;
if (document.getElementById("somename").checked == true) {
document.getElementById("Summary").value = parseInt(DA) + parseInt(500);
} else {
document.getElementById("Summary").value = parseInt(DA);
}
}

UPDATED CODE

关于javascript - 添加下拉列表和复选框值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17305859/

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