Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <meta charset = "windows - 1251">
- <title>Таблица имен</title>
- <style>
- table {
- width: 50%;
- border: 3px solid black;
- border-collapse: collapse;
- margin: auto;
- }
- td, th {
- padding: 2px;
- border: solid black;
- }
- th {
- background: deepskyblue;
- }
- .center {
- text-align: center;
- }
- tbody tr:hover {
- background: cyan;
- }
- </style>
- </head>
- <body>
- <script>
- function randomValue(min, max) {
- return Math.floor(Math.random() * (max - min + 1) + min);
- }
- amount = +prompt("Введите количество полей:");
- document.write ('<p align = "center" style = "font-size: 30px">Таблица персональных даних</p>');
- document.write ('<table>');
- document.writeln('<tr> <th>№</th><th>Ф.И.О.</th><th>Год рождения</th><th>Вес</th> </tr>');
- for (var i = 0; i < amount; i++) {
- var name = prompt("Введите Ф.И.О." + (i + 1) +" - го человека");
- if (name.trim() == ""){
- do {
- name = prompt("Вы ничего не ввели. Попробуйте еще раз:")
- } while (name.trim() == "");}
- document.writeln('<tr class = "center">');
- document.writeln('<td>' + (i + 1) + '</td>');
- document.writeln('<td>' + name + '</td>');
- document.writeln('<td>' + randomValue(1900, 2016) + '</td>');
- document.writeln('<td>' + randomValue(3, 150) + '</td>');
- document.writeln('</tr>');
- }
- document.write ('</table>');
- </script>
- </body>
- </html>
- function openWin() {
- myWindow=window.open('','','width=200,height=100');
- myWindow.document.write(document.getElementById('data').outerHTML);
- myWindow.focus();
- }
Add Comment
Please, Sign In to add comment