急,js与html问题,帮帮忙,在线等 如果是submit按钮就用 onsubmit事件 button的话可以用 onclick() 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 form中的input控件是一起提交的,怎么可能有的提交有的不提交<html><head><title>前端设备基本参数设置</title><script type="text/javascript"> function testpost(){ var fobj=document.getElementsByTagName("input"); for (var i=0;i<fobj.length ; i++) { if(fobj[i].type=="text") if(fobj[i].value == null || fobj[i].value == "") { return; } } document.getElementsByName("form_set")[0].submit(); }</script></head><body><h1>前端设备基本参数设置</h1><p></p>测试URL:SetPuBasicInfo<p></p><form name="form_set" id="form_set" method="get" action="SetPuBasicInfo"><table border="2"><tr><td>puId</td><td><input type="text" name="puId"></td><td>string(32)</td><td>PU的标识</td></tr><tr><td>puName</td><td><input type="text" name="puName"></td><td>string(32)</td><td>PU的名称</td></tr><tr><td>puPassword</td><td><input type="text" name="puPassword"></td><td>string(32)</td><td>PU的设备密码</td></tr></table><input type="button" onclick="testpost()"></form></body></html> 你用的<input type="submit">提交按钮 事件是onsubmit (在form 表单里用 onsubmit=“testpost('form_set')”) <html><head><title>前端设备基本参数设置</title><script type="text/javascript"> function testpost(name) { var isTrue = "false"; var fobj=document.getElementById(name); for (var i=0; i< fobj.length ; i++) { alert(fobj.elements[i].value); if( fobj.elements[i].value == "") { isTrue = "true"; } } if ( isTrue == "false" ) { alert("ok"); fobj.action = "2.htm"; alert(fobj.action); } else { alert("该项不能提交"); } }</script></head><body><h1>前端设备基本参数设置</h1><p></p>测试URL:SetPuBasicInfo<p></p><form name="form_set" id="form_set" ><table border="2"><tr><td>puId</td><td><input type="text" name="puId"></td><td>string(32)</td><td>PU的标识</td></tr><tr><td>puName</td><td><input type="text" name="puName"></td><td>string(32)</td><td>PU的名称</td></tr><tr><td>puPassword</td><td><input type="text" name="puPassword"></td><td>string(32)</td><td>PU的设备密码</td></tr></table><input type="submit" id="btn" value="提交" onclick="testpost('form_set')"></form></body></html>你看看吧,这样是可以的 lihui_shine(浪尖赏花) 说的对!form中的input控件是一起提交的,怎么可能有的提交有的不提交。但是你可以在action="SetPuBasicInfo" action指向的页面中对传递过来的参数判断那个参数是空的 如果form中的input控件是一起提交的,那能不能用javascript去提交呢? 你的form对象.submit();我在3楼用过的 怎样用js实现文字的环形旋转? 高分求51job、智联招聘JS代码 令我莫名其妙了两天的问题,求教各位 在input输入框失去焦点,根据input的值是否为空,显示提示信息。 怎样可以获得cursor 指住的文字? 正则表达式 replace全部替换中文字符时候出现问题!! 如何实现滚动条居中 请教一个问题! 菜单被其它网页元素挡住了? 新手求救,简单问题,大家来帮帮忙! 帮忙找一个帖子(地址).
<head>
<title>前端设备基本参数设置</title><script type="text/javascript"> function testpost(){
var fobj=document.getElementsByTagName("input");
for (var i=0;i<fobj.length ; i++)
{
if(fobj[i].type=="text")
if(fobj[i].value == null || fobj[i].value == "")
{
return;
}
}
document.getElementsByName("form_set")[0].submit(); }</script></head>
<body>
<h1>前端设备基本参数设置</h1><p></p>测试URL:SetPuBasicInfo<p></p>
<form name="form_set" id="form_set" method="get" action="SetPuBasicInfo">
<table border="2">
<tr>
<td>puId</td>
<td><input type="text" name="puId"></td>
<td>string(32)</td>
<td>PU的标识</td>
</tr>
<tr>
<td>puName</td>
<td><input type="text" name="puName"></td>
<td>string(32)</td>
<td>PU的名称</td>
</tr>
<tr>
<td>puPassword</td>
<td><input type="text" name="puPassword"></td>
<td>string(32)</td>
<td>PU的设备密码</td>
</tr>
</table>
<input type="button" onclick="testpost()">
</form>
</body>
</html>
<head>
<title>前端设备基本参数设置</title><script type="text/javascript"> function testpost(name)
{
var isTrue = "false";
var fobj=document.getElementById(name); for (var i=0; i< fobj.length ; i++)
{
alert(fobj.elements[i].value);
if( fobj.elements[i].value == "")
{
isTrue = "true";
}
} if ( isTrue == "false" )
{
alert("ok");
fobj.action = "2.htm";
alert(fobj.action);
}
else
{
alert("该项不能提交");
} }</script></head>
<body>
<h1>前端设备基本参数设置</h1><p></p>测试URL:SetPuBasicInfo<p></p>
<form name="form_set" id="form_set" >
<table border="2">
<tr>
<td>puId</td>
<td><input type="text" name="puId"></td>
<td>string(32)</td>
<td>PU的标识</td>
</tr>
<tr>
<td>puName</td>
<td><input type="text" name="puName"></td>
<td>string(32)</td>
<td>PU的名称</td>
</tr>
<tr>
<td>puPassword</td>
<td><input type="text" name="puPassword"></td>
<td>string(32)</td>
<td>PU的设备密码</td>
</tr>
</table>
<input type="submit" id="btn" value="提交" onclick="testpost('form_set')">
</form>
</body>
</html>
你看看吧,这样是可以的