gpt4 book ai didi

javascript - 进行计算时显示消息 javascript

转载 作者:行者123 更新时间:2023-12-02 19:30:19 26 4
gpt4 key购买 nike

我环顾四周,似乎不知道如何做到这一点,尽管看起来很简单。(移动开发)

我想做的是在进行计算时显示一条消息(有点像警报,但不是警报,更像是对话框)。简单的就像一个正在加载,请稍候。我希望该消息在计算完成时出现并保留在那里,然后将其删除。我似乎找不到合适的方法来做到这一点。

按下提交按钮,首先检查以确保所有表单均已填写,然后应显示消息,进行计算,然后隐藏消息。

这是计算函数。

   function scpdResults(form) {
//call all of the "choice" functions here
//otherwise, when the page is refreshed, the pulldown might not match the variable
//this shouldn't be a problem, but this is the defensive way to code it
choiceVoltage(form);
choiceMotorRatingVal(form);
getMotorRatingType();
getProduct();
getConnection();
getDisconnect();
getDisclaimer();
getMotorType();

//restore these fields to their default values every time submit is clicked
//this puts the results table into a known state
//it is also used in error checking in the populateResults function
document.getElementById('results').innerHTML = "Results:";
document.getElementById('fuse_cb_sel').innerHTML = "Fuse/CB 1:";
document.getElementById('fuse_cb_sel_2').innerHTML = "Fuse/CB 2:";
document.getElementById('fuse_cb_result').innerHTML = "(result1)";
document.getElementById('fuse_cb_res_2').innerHTML = "(result2)";
document.getElementById('sccr_2').innerHTML = "<b>Fault Rating:</b>";
document.getElementById('sccr_result').innerHTML = "(result)";
document.getElementById('sccr_result_2').innerHTML = "(result)";
document.getElementById('contactor_result').innerHTML = "(result)";
document.getElementById('controller_result').innerHTML = "(result)";

//Make sure something has been selected for each variable
if (product === "Choose an Option." || product === "") {
alert("You must select a value for every field. Select a Value for Product");
**************BLAH************
} else {

//valid entries, so jump to results table
document.location.href = '#results_a';


******This is where the message should start being displayed***********

document.getElementById('motor_result').innerHTML = motorRatingVal + " " + motorRatingType;
document.getElementById('voltage_res_2').innerHTML = voltage + " V";
document.getElementById('product_res_2').innerHTML = product;
document.getElementById('connection_res_2').innerHTML = connection;
document.getElementById('disconnect_res_2').innerHTML = disconnect;

if (BLAH) {

}
else {

}

populateResults();
document.getElementById('CalculatedResults').style.display = "block";

} //end massive else statement that ensures all fields have values


*****Close out of the Loading message********
} //scpd results

感谢大家抽出宝贵的时间,非常感谢

最佳答案

最好将显示代码与计算代码分开。大致应该是这样的

displayDialog();
makeCalculation();
closeDialog();

如果您在执行上述任何步骤时遇到问题,请将其添加到您的问题中。

关于javascript - 进行计算时显示消息 javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11568028/

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