页面上有一个一行一列的table(其他按钮,文本框之类的请无视),希望按下时向后台传值,具体看下面代码中的doAction() 这个方法。在执行到submit时提示页面错误(页面左下角出现黄色惊叹号),说对象不支持此属性或方法。document.forms[0].submit();submit本身语法不应该有错误的。现在完全搞不清状况了。求救。
<html lang= "zh ">
<head>
<title> Hello - A first Struts program </title>
<base href= "http://localhost:8088/helloapp/ ">
<script language= "JavaScript " type= "text/JavaScript ">
<!--
function mOver(obj){
obj.parentElement.rows(obj.sectionRowIndex).style.backgroundColor= 'lightblue ';
}
function mOut(obj){
obj.parentElement.rows(obj.sectionRowIndex).style.backgroundColor= ' ';
}
function doAction(obj){
if(obj.name == "searchList "){
document.forms[0].ukechuBmCd.value = obj.cells(1).innerText;
document.forms[0].comotoBmCd.value = obj.cells(2).innerText;
document.forms[0].shiiresakiCd.value = obj.cells(3).innerText;
alert(document.forms[0].ukechuBmCd.value);
alert(document.forms[0].comotoBmCd.value);
alert(document.forms[0].shiiresakiCd.value);
}
document.forms[0].actionType.value = "list ";
alert( "submit ");
document.forms[0].submit();
}
function submitAction(actionType) {
document.forms[0].actionType.value = actionType;
document.forms[0].submit();
}
-->
</script>
</head>
<body bgcolor= "white "> <p>
<h2> Hello World! A first Struts application </h2> <p>
<p>
<form name= "HelloForm " method= "post " action= "/helloapp/HelloWorld.do; ">
<input type= "hidden " name= "actionType " value= " ">
<input type= "hidden " name= "ukechuBmCd " value= " ">
<input type= "hidden " name= "comotoBmCd " value= " ">
<input type= "hidden " name= "shiiresakiCd " value= " ">
Please enter a UserName to say hello to :
<input type= "text " name= "userName " maxlength= "16 " size= "16 " value= " "> <br>
<input type= "submit " name= "submit " value= "Submit " onclick= "javascript:submitAction( 'submit ') ">
<input type= "reset " value= "Reset ">
<input type= "submit " name= "next " value= "nextpage " onclick= "javascript:submitAction( 'next ') ">
<br>
<table>