1

我正在制作一个 Web 应用程序,它采用 JavaScript 变量并将它们放入数学问题中。脚本是

    <HTML>
    <head>
    <meta name="viewport" content="initial-scale=2, user-scalable=no">
    <meta name= apple-mobile-web-app-capable content= yes />
    <meta name= apple-mobile-web-app-status-bar-style content= black />
    <link rel="apple-touch-icon" href="https://dl.dropboxusercontent.com/u/11681462/untitled%20folder/Icon/Icon-SD-Iphone.png" />
    <link rel="apple-touch-icon" sizes= 114x114 href="https://dl.dropboxusercontent.com/u/11681462/untitled%20folder/Icon/Icon-HD-Iphone.png" />
    <link rel="apple-touch-icon" sizes= 72x72 href="https://dl.dropboxusercontent.com/u/11681462/untitled%20folder/Icon/Icon-SD-Ipad.png" />
    <link rel="apple-touch-icon" sizes= 144x144 href="https://dl.dropboxusercontent.com/u/11681462/untitled%20folder/Icon/Icon-HD-Ipad.png" />
    <Title> Diabetes Cal </Title>
    <script>
    function valuechanged() {
    var a = document.getElementById('textA').value;
    var b = document.getElementById('textB').value;
    var t = document.getElementById('textX').value;
    var y = document.getElementById('textY').value;
    var z = document.getElementById('textZ').value;
    var dec = t * 0.1;
    var x = parseFloat(dec).toFixed(1);
    if (+x - +y < 0) {
        var c = 0;
    }
         else
        {
            c = +x - +y;
        } 
       if (c < 0) {
        var l = 0;
       }
        else
        {
        var l = c / z;
        }
        var d = parseFloat(l).toFixed(2);
        if (a / b < 0)
        {
        var u = 0;
        }
        else
        {
        var u = a / b;
        }
        var e = parseFloat(u).toFixed(2);
            document.getElementById('labelS').innerHTML = e;
        document.getElementById('labelG').innerHTML = d;
        document.getElementById('labelX').innerHTML = 
        document.getElementById('labelJ').innerHTML = +d + +e;
            }
        function myFunction(){  
    var TS=document.getElementById('textB')
     var date= new Date();
     var time = date.getHours();
    if (time<10)
         {
          CR = "8";
          }
        else if (time<16)
         {
          CR = "10";
          }
        else if (time<20)
         {
          CR = "5";
          }
        else
         {
         CR = "8";
          }
    TS.value= CR
    }
        </script>
    </head>
    <body BGColor=orange onload="valuechanged();myFunction();" > <center><br> Bolus Wizard <br>
         <div>
         Bg (without Decimal)<br> 
        <input type="text" pattern=\d* id="textX" min="25" max="333" value="25" onchange="valuechanged();" /><br><label ID="labelX">-----</label> mmol/L<br>

        </div><hr width=45% color=black size=0.5>
        <div>
          Carbs<br> <input type="text" pattern=\d* ID="textA" max=300 value="0" onchange="valuechanged();" /><br>
        </div><hr width=45% color=black size=0.5>
        <div>
            Carb Ratio<br><input type="text" pattern=\d* ID="textB" value="" onchange="valuechanged();" /> 
        </div>
        <div>
            Target<br><input type="text" pattern=\d* ID="textY" value="6" onchange="valuechanged();" />
        </div>
    <div>
            Correction Factor<br><input type="text" pattern=\d* ID="textZ" value="2" onchange="valuechanged();" />
        </div>
    <div>
            Food<br>  <label ID="labelS">  ---</label> Units
        </div>
    <p>
    <div>
            Correction<br>  <label ID="labelG">  ---</label> Units
        </div>
    <p>
        <div>
            You Need...<br>  <label ID="labelJ">  ---    </label> Units
        </div>
    <p>
    </center>
    </body>
    </HTML> 

我希望有人可以帮助我为 textB TextY 和 TextZ 制作一个设置页面。它需要在不同的页面上。这个网络应用程序是为 Iphone 和 iPad 设计的。此外,如果无论如何要将 var CR 的变量更改为设置(例如文本框显示上午 8 点,另一个显示上午 10 点)并将其保存在设备上,您能否将其作为答案包含在内。谢谢,你真的会帮上大忙。

4

0 回答 0