在asp中有关onclick与onsubmit冲突的问题
<scriptlanguage="javascript">functionca(){if(document.form.guige.value==""){alert("请输...
<script language="javascript">
function ca()
{
if(document.form.guige.value=="")
{alert("请输入柜体规格!");
form.guige.focus();
return false;
}
return true;
}
</script>
<script language="javascript">
function ad()
{
var temp=document.form.guiti_name.value;
document.form.action=temp;
document.form.submit();
}
</script>
<body>
<form action="" method="post" name="form" onSubmit="return ca();">
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablebk">
<tr class="table_trbg02" height="30" align="center">
<td >柜体属性</td>
<td >
<select name="guiti_name" id="guiti_name">
<option value="1.asp?action=chaidan&name1=<%=request("name")%>">落地水柜</option>
<option value="guiti.asp?action=chaidan&name1=<%=request("name")%>">落地柜</option>
<option value="3.asp?action=chaidan&name1=<%=request("name")%>">试剂柜</option>
</select></td>
<td >规格</td>
<td width="15%"> <input type="text" name="guige"></td>
<td ><input name="" type="button" value="提 交" onClick="return ad();"></td>
</tr>
</table>
</form>
当单击提交按钮时,不会执行onSubmit事件,这是怎么回事?是思路不对还是语法不对,请高人指点。 展开
function ca()
{
if(document.form.guige.value=="")
{alert("请输入柜体规格!");
form.guige.focus();
return false;
}
return true;
}
</script>
<script language="javascript">
function ad()
{
var temp=document.form.guiti_name.value;
document.form.action=temp;
document.form.submit();
}
</script>
<body>
<form action="" method="post" name="form" onSubmit="return ca();">
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablebk">
<tr class="table_trbg02" height="30" align="center">
<td >柜体属性</td>
<td >
<select name="guiti_name" id="guiti_name">
<option value="1.asp?action=chaidan&name1=<%=request("name")%>">落地水柜</option>
<option value="guiti.asp?action=chaidan&name1=<%=request("name")%>">落地柜</option>
<option value="3.asp?action=chaidan&name1=<%=request("name")%>">试剂柜</option>
</select></td>
<td >规格</td>
<td width="15%"> <input type="text" name="guige"></td>
<td ><input name="" type="button" value="提 交" onClick="return ad();"></td>
</tr>
</table>
</form>
当单击提交按钮时,不会执行onSubmit事件,这是怎么回事?是思路不对还是语法不对,请高人指点。 展开
1个回答
展开全部
我帮你修改了,注意几点
1、只用了function ca()
2、<input name="" type="button" value="提 交" onClick="return ad();">修改为:<input name="" type="submit" value="提 交" >
=====修改后代码===========
<script language="javascript">
function ca()
{
var temp=document.form.guiti_name.value;
document.form.action=temp;
if(document.form.guige.value=="")
{alert("请输入柜体规格!");
form.guige.focus();
return false;
}
return true;
}
</script>
<body>
<form action="" method="post" name="form" onSubmit="return ca();">
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablebk">
<tr class="table_trbg02" height="30" align="center">
<td >柜体属性</td>
<td >
<select name="guiti_name" id="guiti_name">
<option value="1.asp?action=chaidan&name1=<%=request("name")%>">落地水柜</option>
<option value="guiti.asp?action=chaidan&name1=<%=request("name")%>">落地柜</option>
<option value="3.asp?action=chaidan&name1=<%=request("name")%>">试剂柜</option>
</select></td>
<td >规格</td>
<td width="15%"> <input type="text" name="guige"></td>
<td ><input name="" type="submit" value="提 交"></td>
</tr>
</table>
</form>
1、只用了function ca()
2、<input name="" type="button" value="提 交" onClick="return ad();">修改为:<input name="" type="submit" value="提 交" >
=====修改后代码===========
<script language="javascript">
function ca()
{
var temp=document.form.guiti_name.value;
document.form.action=temp;
if(document.form.guige.value=="")
{alert("请输入柜体规格!");
form.guige.focus();
return false;
}
return true;
}
</script>
<body>
<form action="" method="post" name="form" onSubmit="return ca();">
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablebk">
<tr class="table_trbg02" height="30" align="center">
<td >柜体属性</td>
<td >
<select name="guiti_name" id="guiti_name">
<option value="1.asp?action=chaidan&name1=<%=request("name")%>">落地水柜</option>
<option value="guiti.asp?action=chaidan&name1=<%=request("name")%>">落地柜</option>
<option value="3.asp?action=chaidan&name1=<%=request("name")%>">试剂柜</option>
</select></td>
<td >规格</td>
<td width="15%"> <input type="text" name="guige"></td>
<td ><input name="" type="submit" value="提 交"></td>
</tr>
</table>
</form>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询