Web应用程序的设置

时间:2013-06-27 05:43:41

标签: javascript web-applications var

我正在创建一个带有JavaScript变量的Web应用程序并将它们置于数学问题中。脚本是

    <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的设置页面。它需要在不同的页面上。此Web应用程序专为Iphone和iPad设计。另外,如果无论如何都要将var CR的变量更改为设置(如文本框说早上8点,另一个说早上10点)并将其保存在设备上,是否可以将其作为答案包含在内。谢谢,你真的会帮助很多。

0 个答案:

没有答案