<form name="form" method="GET" action="test.php" onSubmit="return formcheck();">
……
<INPUT class="input" id="hdate1" style="WIDTH: 120px"
onclick="event.cancelBubble=true;showCalendar('./','hdate1',false,'hdate1')"
size=12 name="fr" >
……
</form>
上面是日历控件应用,在文本域中单击边弹出日历控件,我想在选择日期后,不用点击任何按钮或回车就能自动提交,如何实现?我在input标签加上onchange="javascript:submit()"代码也没有?大家谁能给我答案?
onchange="javascript:this.form.submit()"
http://download.csdn.net/source/308913JScript 语言参考
http://download.csdn.net/source/308916CCS 样式表中文手册
http://download.csdn.net/source/304124
<!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>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="[email protected]" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>
<body>
<form method="post" action="http://www.baidu.com/">
<input type="text" id="" onchange="this.form.submit();" value="" />
</form>
</body>
</html>
指定的onSubmit里的formcheck()影响到不能直接提交this.form.submit();
但这样,缺乏控制,肯定是不好的.
感觉现在很多问题为什么非要弄得那么奇怪呢.好好想想利弊.
<input type="text" id="" onchange="this.form.submit();" value="" />
文本域要在form表单内,如果没有form或是在外面就不对</form>or document.forms[0].submit();
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<form name="form" method="GET" action="http://www.baidu.com" onSubmit="return formcheck();">
<INPUT class="input" id="hdate1" style="WIDTH: 120px"
size=12 name="fr" onchange="this.form.submit();">
</form>
</body>
</html>
如果没有插入日历选择的控件的时候,可以跳转,如上面test1;但如果插入日历的时候却不行了,如下test2。那个日期选择日历下载地址为http://download.csdn.net/source/2657432,应该是onclick出了问题了,大家谁能帮我试试?
test2<!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=gb2312" />
<title>无标题文档</title><script src="./js/calendar.js"></script></head>
<body>
<form name="form" method="GET" action="http://www.baidu.com" onSubmit="return formcheck();">
<INPUT class="input" id="hdate1" style="WIDTH: 120px"
onclick="event.cancelBubble=true;showCalendar('./','hdate1',false,'hdate1')"
size=12 name="fr" onchange="this.form.submit();">
</form>
</body>
</html>
问题是,这样的需求想法,随便给一个有几年的实际经验的工程师来看,都是极不可取的。
日期的选择,属于极不固定的输入项目,存在误点击的情况,比输入错误文本的机会还要大得多。
因此,在日期输入框的ONCHANGE来即时自动提交的话——而且此时其它项目是否也已输入完毕是还需要验证的——有点不可想象。除非是在极其特殊的情况下,而且效率比正确性重要得多或者正确性完全可以保证的时候。
真正解决问题,并不是给你一段能实现的具体代码,而是要看你这个问题到底应该怎么办。应该实现的,就给你代码,不应该实现的,负责任的态度就是提醒你好好认真想想是否应该去实现这种带有重大隐患的想法。
还是在当前页面构建了dom造成form表单不能提交,你自己检查下
with(document.getElementById('form')) {
submit()
}