请教用div的onclick事件来提交表单的方法
白马老丸子 2006-08-18 09:21:19 这个是我的代码
1.这个是用按钮提交的,可以成功提交
<table height="30" border="0" cellpadding="0" cellspacing="5">
<FORM name=formName action="searchResults.jsp" >
<tr>
<td width="350">
<input name="query" type="text" class="input" value="请输入关键字" size="35" onClick="javascript:if (this.value=='请输入关键字'){this.value=''}">
<input name="submit" type="submit" class="input" value="搜 索">
</td>
</tr>
</form>
</table>
2.这个是用层实现的,报错“对象不支持此属性或方法”
<FORM name=formName action="searchResults.jsp" >
<div id="Layer1" style="position:absolute; width:608px; height:51px; z-index:1; left: 274px; top: 44px; " >
<input name="query2" type="text" class="input" value="请输入关键字" size="35" onClick="javascript:if (this.value=='请输入关键字'){this.value=''}" style="width:100%; height:100%; ">
</div>
<div id="Layer2" style="position:absolute; width:87px; height:78px; z-index:2; left: 909px; top: 32px;" onClick="submitData();">
<table width="100%" height="100%" >
<tr>
<td> </td>
</tr>
</table>
</div>
</form>
<script language="JavaScript">
function submitData()
{
document.formName.submit();
}
</script>
请高手帮忙看看怎么解决?