Hello there are three files:
CW.html with code:
<html> <head> <meta charset = "utf-8"> <title>Таблиця имен</title> <script>src = "tablescript.js"</script> </head> <body></body> </html>
tablestyle.css with code:
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; }
and tablescript with code:
function randomValue(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } function tableMaker() { amount = +prompt("Ввеите кол-во полей:"); var wnd = window.open('#','_blank'); wnd.document.write ('<html>'); wnd.document.write ('<head>'); wnd.document.write ('<title></title>'); wnd.document.write ('<link rel = "stylesheet" type = "text/css" href= "tablestyle.css">'); wnd.document.write ('</head>'); wnd.document.write ('<body>'); wnd.document.write ('<p align = "center" style = "font-size: 30px">Таблица персональных даных </p>'); wnd.document.write ('<table>'); wnd.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() == ""); } wnd.document.writeln('<tr class = "center">'); wnd.document.writeln('<td>' + (i + 1) + '<\/td>'); wnd.document.writeln('<td>' + name + '<\/td>'); wnd.document.writeln('<td>' + randomValue(1900, 2016) + '<\/td>'); wnd.document.writeln('<td>' + randomValue(3, 150) + '<\/td>'); wnd.document.writeln('<\/tr>'); } wnd.document.write ('</table>'); wnd.document.write ('</body>'); wnd.document.write ('</html>'); }
This is my first work with javascript and css, please tell me what is wrong.