日期:2014-05-16  浏览次数:20339 次

关于修改数量后自动提交的问题
<form id="form1" name="form1" method="post" action="">
  <input name="num" type="text" id="num" />
</form>

现在要实现的功能,num域本来有个默认数量,如果修改了数量(和以前的数量不一样),失去焦点后,自动提交,不用点提交按钮,如何失现?

------解决方案--------------------
HTML code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <input name="num" type="text" id="num" onchange='change()' value='10'/>
</form>
<script>
    function change() {
        form1.submit();
    }
</script>
</body>
</html>

------解决方案--------------------
<script type="text/javascript">
function ss(){
 document.forms[0].submit();
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<input name="num" type="text" id="num" value="1" onchange="ss()"/>
</form>
</body>
</html>
这样?
------解决方案--------------------
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload = function() {
    document.getElementById('num').onchange = function() {
        var d = this.value;
        if (!/^[0-9\uFF10-\uFF19]+$/.test(d)) alert('非法数据');
        else {
            d = d.replace(/[\uFF10-\uFF19]+?/g, function(n) {
                return String.fromCharCode(n.charCodeAt(0) - 65248);
            });
            this.value = d;
            this.form.submit();
        }
    }
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
  <input name="num" type="text" id="num" />
</form>
</body>
</html>