87,993
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.3.2.js">
</script>
<script type="text/javascript">
/**
* @author develop_design_level
* @date 2009-11-04
*/
$(function(){
$('#btnId').click(function(){
var inputTextObjArray = document.getElementsByName('hello');
var __arr = [];
$.each(inputTextObjArray, function(i, n){
__arr.push($.trim($(n).val()));//形成所有控件值组成的数组,便于后台进行分割。split(",")
});
var option = {
url: '/your.do',
data: {
array: __arr//传递到后台的参数名称array
},
type:'POST',
dataType:'json',
success:function(rs){
alert('success');
},
error:function(rs){
alert('error')
}
};
$.ajax(option);//执行ajax提交
});
});
</script>
</head>
<body>
<table width="500" border="1">
<tr>
<td>
控件1
</td>
<td>
<input type="text" name="hello">
</td>
</tr>
<tr>
<td>
控件2
</td>
<td>
<input type="text" name="hello">
</td>
</tr>
<tr>
<td>
控件3
</td>
<td>
<input type="text" name="hello">
</td>
</tr>
</table><input type="button" id="btnId" value="提交所以数据"/>
</body>
</html>
=== 结贴,给分 ===
得到满意的答案,立即结贴给分,是一种良好的习惯和美德