我的两个表单代码:
[code]
<script type="text/javascript">
<!--
function Form_Validator(theForm)
{
if(theForm.username){
if(theForm.username.value==""){
alert("Please enter your UserName!");
theForm.username.focus();
return(false);
}
}
if(theForm.password){
if(theForm.password.value==""){
alert("Please enter your Password!!");
theForm.password.focus();
return(false);
}
}
}
//-->
</script> <form name="from1" method="POST" onSubmit="return Form_Validator(this)" >
Name:
<input name="username" type="text" class="input" />
<input type="image" src="images/login.jpg" align="middle" onclick="form1.action='?action=index.php&action=login';form1.submit();" />
<br/>
Password:
<input name="password" type="password" class="input"/>
<img style="cursor:hand;" src="images/reg.jpg" onclick="window.location='index.php?action=reg'">
</from><form name="form" style="margin:0px; padding:0px;" action="?action=search" method="POST" >
Search:<input name="key" class="wenbenkuang" id="key" />
<select name="cid"><option value="0">All Products</option>
</select>
<input type="image" name="submit" src="images/search.gif" align="middle" onclick="form2.action='?action=index.php&action=search';form2.submit();"/>
</form>
[/code]
把搜索放在上面就没事。放在下面。。提交的时候。。就回到form1
[code]
<script type="text/javascript">
<!--
function Form_Validator(theForm)
{
if(theForm.username){
if(theForm.username.value==""){
alert("Please enter your UserName!");
theForm.username.focus();
return(false);
}
}
if(theForm.password){
if(theForm.password.value==""){
alert("Please enter your Password!!");
theForm.password.focus();
return(false);
}
}
}
//-->
</script> <form name="from1" method="POST" onSubmit="return Form_Validator(this)" >
Name:
<input name="username" type="text" class="input" />
<input type="image" src="images/login.jpg" align="middle" onclick="form1.action='?action=index.php&action=login';form1.submit();" />
<br/>
Password:
<input name="password" type="password" class="input"/>
<img style="cursor:hand;" src="images/reg.jpg" onclick="window.location='index.php?action=reg'">
</from><form name="form" style="margin:0px; padding:0px;" action="?action=search" method="POST" >
Search:<input name="key" class="wenbenkuang" id="key" />
<select name="cid"><option value="0">All Products</option>
</select>
<input type="image" name="submit" src="images/search.gif" align="middle" onclick="form2.action='?action=index.php&action=search';form2.submit();"/>
</form>
[/code]
把搜索放在上面就没事。放在下面。。提交的时候。。就回到form1
就是这个写错了。郁闷。。后来看见了。还是很感谢大家 。。谢谢 。