<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:te="
http://www.seasar.org/teeda/extension" lang="ja" xml:lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<script type="text/javascript" src="../../js/jquery.js"></script>
<script type="text/javascript">


function addRow() {
var rowStr = '<tr>';
rowStr += '<td><span id="rowno"></span></td>';
rowStr += '<td><input id="userId" type="text" /></td>';
rowStr += '<td><input type="hidden" id="rowno-1" /></td>';
rowStr += '</tr>';
$('#userItems').append(rowStr);

resetIndex();
}

// 明細のINDEXを振り直す
function resetIndex(){
var nameVal = 'layoutChildBody:form:userItems:';
$('#userItems tr').each(function(idx, obj){
// 行番号を振り直す
$(obj).find('#rowno').text('' + (idx + 1));
// name属性のindexを振りなおす
$(obj).find('#rowno').attr('name', nameVal + idx + ':rowno');
$(obj).find('#userId').attr('name', nameVal + idx + ':userId');
});
}

</script>
</head>
<body>
<span id="allMessages"/>
<form id="form">

<table>
<thead>
<th>ユーザID</th>
</thead>
<tbody id="userItems">
<tr>
<td><span id="rowno"></span></td>
<td><input id="userId" type="text" value="" /></td>
</tr>
</tbody>
</table>
<input type="button" onclick="addRow()" value="ADD ROW"/>
<input type="button" id="doTest" value="TEST" onclick="test()"/>
</form>
</body>
</html>