Javascript 多次单击事件无法正常工作
我对onClick中有两个函数以及如何使其正确工作感到有点困惑。当只使用一个函数,但有两个函数时,“getCustomerList()”不再起作用。任何帮助都将不胜感激。以下是相关代码: HTML:Javascript 多次单击事件无法正常工作,javascript,html,onclick,Javascript,Html,Onclick,我对onClick中有两个函数以及如何使其正确工作感到有点困惑。当只使用一个函数,但有两个函数时,“getCustomerList()”不再起作用。任何帮助都将不胜感激。以下是相关代码: HTML: ... ... 客户属性: JAVASCRIPT: function buttonandchecks() { var x; var output=""; var resultoutput=""; var extra=parseFloat(0); var radio_value; var to
...
...
客户属性:
JAVASCRIPT:
function buttonandchecks()
{
var x;
var output="";
var resultoutput="";
var extra=parseFloat(0);
var radio_value;
var total=parseInt(0);
for(x=0;x<document.costEstimation.special.length;x++)
{
if(document.costEstimation.special[x].checked)
{
radio_value=document.costEstimation.special[x].value;
}
}
radio_value=parseFloat(radio_value);
if(document.costEstimation.AC.checked)
{
extra+=10;
output=(output+" A/C");
}
if(document.costEstimation.WB.checked)
{
extra+=100;
output=(output+" Brakes");
}
if(document.costEstimation.CC.checked)
{
extra+=20;
output=(output+" Cruise Control");
}
if(document.costEstimation.BS.checked)
{
extra+=30;
output=(output+" Baby Seat");
}
total=radio_value+extra;
resultoutput=("Total: " + total.toFixed(2)+ " \nIncluding Extras: " + output);
alert(resultoutput);
}
function getCustomerList () {
var customer={Text1,Lname,Add,City,StPrv,Cntry,Hphn,Wphn};
var i=0;
var thisList="";
customer.Text1=document.getElementById("Text1").value;
customer.Lname=document.getElementById("Lname").value;
customer.Add=document.getElementById("Add").value;
customer.City=document.getElementById("City").value;
customer.StPrv=document.getElementById("StPrv").value;
customer.Cntry=document.getElementById("Cntry").value;
customer.Hphn=document.getElementById("Hphn").value;
customer.Wphn=document.getElementById("Wphn").value;
customerList.push(customer);
for(i=0; i< customerList.length;i++)
{
var thisCustomer={Text1,Lname,Add,City,StPrv,Cntry,Hphn,Wphn};
thisCustomer=customerList[i];
thisList+=thisCustomer.Text1 + " , "+thisCustomer.Lname+" , "+thisCustomer.Add+" , "+thisCustomer.City+" , "+thisCustomer.StPrv+" , "+thisCustomer.Cntry+" , "+thisCustomer.Hphn+" , "+thisCustomer.Wphn;
thisList+="<br>";
}
document.getElementById("currentList").innerHTML=thisList;
}
函数按钮和检查()
{
var x;
var输出=”;
var resultoutput=“”;
var-extra=parseFloat(0);
var比值;
var-total=parseInt(0);
对于(x=0;x也许您应该从按钮和checks();
方法中调用getCustomerList();
function formSubmit() {
buttonandchecks();
getCustomerList();
}
请定义“不再工作”。请注意,通过document
直接引用元素在所有浏览器中都是不推荐的,在某些浏览器中可能已经过时。customer={Text1,Lname,Add,City,StPrv,Cntry,Hphn,wpn};
这是无效的语法,您是否检查了JS控制台中的错误?
function formSubmit() {
buttonandchecks();
getCustomerList();
}