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

标签 javascript jquery mobile dialog

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

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

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

这是计算函数。

   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/

相关文章:

javascript - jquery选择器使用 'not:'两次

jquery - 将 jQuery Datepicker 添加到动态添加的 &lt;input&gt;

javascript - 如何使用sencha嵌入youtube视频

angularjs - AngularJS 中的自适应布局(移动/桌面) - 首选的方式是什么(内部示例)

css - 如何将 css 应用于垂直居中的元素(wordpress)?

javascript - 更改字体系列 Morris Donut Chart

javascript - 如何确定插入的(可能是恶意的)JavaScript 代码来自何处

javascript - 在 Asp MVC 5 中使用 Rotativa PDF 生成器隐藏 PDF 中的打印按钮和导航菜单

javascript - 检测内联样式左值变化和 div 没有 id

javascript - 如何使用正则表达式从字符串中删除带有 HTML 标签的 HTML 标签的内部文本?