0

到目前为止,我没有成功让第一个输入按钮启动表移位功能。目前我正在测试功能。我已经尽力通过一些教科书和在线搜索来查看格式,我认为我的语法是正确的。寻找关于为什么没有从按钮计算班次引用 tableShifts() 的建议。谢谢你。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Couch Shifts</TITLE>
<script type="text/javascript">     

    function openWindow() 
        {
            window.open('','',"toolbar=no, menubar=no, directories=no, status=no, resizable=no, scrollbars=no, height=120,width=510");
        }

    function patientPosition()
        {
            var x = 1;
            var Position = document.getElementbyId("Position").value;
            switch (patPosition){
            case "HFS":
                x = x*1         
            case "HFP":
                x = x*-1            
            case "FFS":
                x = x*1         
            case "FFP":
                x = x*-1        
            }
        }

    function tableShifts() 
        {
            alert("test");
        }

    function parameters()
       {           
            var curVert = Number(document.getElementById("curVert").value),
            var curLat = Number(document.getElementById("curLat").value), 
            var curLong = Number(document.getElementById("curLong").value), 

            var pinVert = Number(document.getElementById("curVert").value),
            var pinLat = Number(document.getElementById("curVert").value),
            var pinLong = Number(document.getElementById("curVert").value);

            document.getElementById("gotoVert").value = curVert - pinVert;
            document.getElementById("gotoLat").value  = curLat + pinLat;
            document.getElementById("gotolong").value = curLong - pinLong; 
            }

</script>
  </HEAD>
  <BODY>
<select Id="Position">
    <option value="HFS">Head First Supine</option>
    <option value="HFP">Head First Prone</option>
    <option value="FFS">Feet First Supine</option>
    <option value="FFP">Feet First Prone</option>
</select><br><br>
<div style="margin-bottom: 120px;">
<style>
    label { float: left; width: 35px; }
    #column1{ float: left; position: relative; z-index: 0; width: 150px;}
    #column2{ float: left; position: relative; z-index: 2; width: 150px;}
    #column3{ float: left; position: relative; z-index: 1; width: 125px;}
    #button { position: absolute; }
</style>
<div id="column1">Current Position</br></br>
    <label for="Vert">Vert:</label>
    <input type="text", id="curVert" size="10" value="" /></br>
    <label for="Lat">Lat:</label>
    <input type="text" size="10", id="curLat" value="" /></br>
    <label for="Long">Long:</label>
    <input type="text" size="10", id="curLong" value="" />  
</div>

<div id="column2">Pinnicle Shifts<br><br>
    <label for="Vert">Vert:</label>
    <input type="text", id="pinVert" size="10" value="" /></br>
    <label for="Lat">Lat:</label>
    <input type="text", id="pinLat" size="10" value="" /></br>
    <label for="Long">Long:</label>
    <input type="text", id="pinLong" size="10" value="" />      
</div>

<div id="column3">Calculated Shifts</br></br>
    <label for="Vert">Vert:</label>
    <input type="text", id="gotoVert" size="10" value="" readonly="readonly" style="background-color:#D8D8D8 ;"/></br>
    <label for="Lat">Lat:</label>
    <input type="text", id="gotoLat" size="10" value="" readonly="readonly" style="background-color:#D8D8D8 ;"/></br>
    <label for="Long">Long:</label>
    <input type="text", id="gotoLong" size="10" value="" readonly="readonly" style="background-color:#D8D8D8 ;"/>       
</div><br />
</div>

<div id="button">
    <input type = "button" style="margin-top: 10px;" value="Calculate Shifts" onclick="tableShifts();" />
    <input type = "button" style="margin-top: 10px;" value="Reset" onclick=""/>
 </div> 
</BODY>
</HTML>
4

3 回答 3

0

在功能上tableShiftsss你有:

    var gotoVert.value = curVert - pinVert;
    var gotoLat.value = curLat + pinLat;
    var gotolong.value = curLong - pinLong;

这不是有效的 EcmaScript 方言(如 javascript)。

您可能希望将其更改为:

function tableShifts(){           
    var curVert = Number(document.getElementById("curVert").value),
         curLat = Number(document.getElementById("curLat").value), 
        curLong = Number(document.getElementById("curLong").value), 

        pinVert = Number(document.getElementById("curVert").value),
         pinLat = Number(document.getElementById("curVert").value),
        pinLong = Number(document.getElementById("curVert").value);

    document.getElementById("gotoVert").value = curVert - pinVert;
    document.getElementById("gotoLat").value  = curLat + pinLat;
    document.getElementById("gotolong").value = curLong - pinLong; 
}

祝你好运!

于 2013-04-12T01:49:11.567 回答
0

在你的 tableShiftsss() 里面,你说:

var gotoVert.value

虽然它应该是:

document.getElementById("gotoVert").value

这适用于所有这三个陈述。

此外,value 函数返回一个字符串而不是 int,因此您不能只添加结果。相反,您需要像这样转换为 int:

var curVert = parseInt(document.getElementById("curVert").value);

您可能还有其他语法错误,但这取决于您使用浏览器的 Javascript 控制台进行调试。

于 2013-04-12T01:51:44.160 回答
0

尝试这个

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
        <HTML>
        <HEAD>
        <TITLE>Couch Shifts</TITLE>
        <script type="text/javascript">     



            function tableShifts() 
                {
                    alert("test");
                }

        function openWindow() 
                {
                    window.open('','',"toolbar=no, menubar=no, directories=no, status=no, resizable=no, scrollbars=no, height=120,width=510");
                }

          function patientPosition()
                {
                    var x = 1;
                    var Position = document.getElementbyId("Position").value;
                    switch (patPosition){
                    case "HFS":
                        x = x*1         
                    case "HFP":
                        x = x*-1            
                    case "FFS":
                        x = x*1         
                    case "FFP":
                        x = x*-1        
                    }
                }

             function parameters()
               {           
                    var curVert = Number(document.getElementById("curVert").value);
                    var curLat = Number(document.getElementById("curLat").value);
                    var curLong = Number(document.getElementById("curLong").value); 

                   var pinVert = Number(document.getElementById("curVert").value);
                    var pinLat = Number(document.getElementById("curVert").value);
                    var pinLong = Number(document.getElementById("curVert").value);

                    document.getElementById("gotoVert").value = curVert - pinVert;
                    document.getElementById("gotoLat").value  = curLat + pinLat;
                    document.getElementById("gotolong").value = curLong - pinLong;
                    }

        </script>
          </HEAD>
          <BODY>
        <select Id="Position">
            <option value="HFS">Head First Supine</option>
            <option value="HFP">Head First Prone</option>
            <option value="FFS">Feet First Supine</option>
            <option value="FFP">Feet First Prone</option>
        </select><br><br>
        <div style="margin-bottom: 120px;">
        <style>
            label { float: left; width: 35px; }
            #column1{ float: left; position: relative; z-index: 0; width: 150px;}
            #column2{ float: left; position: relative; z-index: 2; width: 150px;}
            #column3{ float: left; position: relative; z-index: 1; width: 125px;}
            #button { position: absolute; }
        </style>
        <div id="column1">Current Position</br></br>
            <label for="Vert">Vert:</label>
            <input type="text" id="curVert" size="10" value="" /></br>
            <label for="Lat">Lat:</label>
            <input type="text" size="10" id="curLat" value="" /></br>
            <label for="Long">Long:</label>
            <input type="text" size="10" id="curLong" value="" />  
        </div>

        <div id="column2">Pinnicle Shifts<br><br>
            <label for="Vert">Vert:</label>
            <input type="text", id="pinVert" size="10" value="" /></br>
            <label for="Lat">Lat:</label>
            <input type="text", id="pinLat" size="10" value="" /></br>
            <label for="Long">Long:</label>
            <input type="text", id="pinLong" size="10" value="" />      
        </div>

        <div id="column3">Calculated Shifts</br></br>
            <label for="Vert">Vert:</label>
            <input type="text", id="gotoVert" size="10" value="" readonly="readonly" style="background-color:#D8D8D8 ;"/></br>
            <label for="Lat">Lat:</label>
            <input type="text", id="gotoLat" size="10" value="" readonly="readonly" style="background-color:#D8D8D8 ;"/></br>
            <label for="Long">Long:</label>
            <input type="text", id="gotoLong" size="10" value="" readonly="readonly" style="background-color:#D8D8D8 ;"/>       
        </div><br />
        </div>

        <div id="button">
            <input type = "button" style="margin-top: 10px;" value="Calculate Shifts" onclick="tableShifts();" />
            <input type = "button" style="margin-top: 10px;" value="Reset" onclick=""/>
         </div> 
        </BODY>
        </HTML>
于 2013-04-12T04:00:02.247 回答