There are problems with writing a script that displays a table with the names of people, the year of birth is a random number 1900 - 2016, and a weight of 3 is 150.
It is necessary that the table be displayed on a separate tab of the browser . It is necessary that there was a function that builds the table, and then when creating window.open () this function was called? I understand, it will sound brazenly, but correct my code.
<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>