首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

小弟我的JS为什么不执行

2013-01-23 
我的JS为什么不执行啊inputtypetext idquntity value1onkeydownautoCount() onkeyupautoCo

我的JS为什么不执行啊


    <input  type="text" id="quntity" value="1"  onkeydown="autoCount()" onkeyup="autoCount()"  style="text-align:center; width:58px; height:20px;"  maxlength="3"  />
<input type="button" id="buy" value="确认无误,购买" onclick="submit()" />
        <script>
            function submit() {
                var count = parseInt(document.getElementById("quntity").value);
                if (count == "" || isNaN(count)) {
                    alert("商品数量必须为数字");
                }
            }
        </script>
[解决办法]
经验证   执行了啊 

<html>
<body>
<input  type="text" id="quntity" value="1"  onkeydown="autoCount()" onkeyup="autoCount()"  style="text-align:center; width:58px; height:20px;"  maxlength="3"  />
<input type="button" id="buy" value="确认无误,购买" onclick="submit()" />
        <script>
            function submit() {
                alert(1)
                var count = parseInt(document.getElementById("quntity").value);alert(count);
                if (count == "" 
[解决办法]
 isNaN(count)) {
                    alert("商品数量必须为数字");
                }
            }
        </script>
</body>
</html>

[解决办法]
submit()函数改个名字。也许是和submit关键字冲突了。
[解决办法]
引用:
<input  type="text" id="quntity" value="1"  onkeydown="autoCount()" onkeyup="autoCount()"  style="text-align:center; width:58px; height:20px;"  maxlength="3"  />
<input type="button" id="buy" val……

脚本段中加入alert("脚本运行了")这样便知是否运行,
不运行的猜测:
1.脚本存在语法错误,导致整个代码段未加载
2.不要使用“submit”作为函数名,换个试试!
3.脚本未指明类型!
[解决办法]
引用:
引用:<input  type="text" id="quntity" value="1"  onkeydown="autoCount()" onkeyup="autoCount()"  style="text-align:center; width:58px; height:20px;"  maxlength="3"  />


<input ……


+++ 听完整了

顺便说下  可以配合火狐的firebug来进行js的调试

热点排行