Показать сообщение отдельно
  #3 (permalink)  
Старый 27.11.2011, 12:21
Аватар для ksa
ksa ksa вне форума
CacheVar
Отправить личное сообщение для ksa Посмотреть профиль Найти все сообщения от ksa
 
Регистрация: 19.08.2010
Сообщений: 14,127

Как вариант...

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<!--
<link rel="stylesheet" type="text/css" href="tmp.css" />
-->
<style type="text/css">
</style>
<script type="text/javascript">
var a=[
	{'fam': 'Иванов', 'name': 'Иван', 'otch': 'Иванович'},
	{'fam': 'Петров', 'name': 'Пётр', 'otch': 'Петрович'}
];
$(document).ready(function(){
	$("button").click(function() {
		var i;
		var str;
		for (i=0; i<a.length; i++) {
			str='<tr>';
			str+='<td>';
			str+=a[i].fam
			str+='</td>';
			str+='<td>';
			str+=a[i].name
			str+='</td>';
			str+='<td>';
			str+=a[i].otch
			str+='</td>';
			str+='</tr>';
			$('#data').append(str);
		};
	});
});
</script>
</head>
<body>
<table width="100" border="1" cellspacing="10" cellpadding="10">
	<thead>
		<tr>
			<th scope="col" id="fam0">&nbsp;</th>
			<th scope="col" id="name0">&nbsp;</th>
			<th scope="col" id="otch0">&nbsp;</th>
		</tr>
	</thead>
	<tbody id='data'>
		<tr>
			<td  id="fam1">&nbsp;</td>
			<td id="name1">&nbsp;</td>
			<td id="otch1">&nbsp;</td>
		</tr>
	</tbody>
</table>
<button>Add</button>
</body>
</html>
Ответить с цитированием