add javascripts excercise
This commit is contained in:
parent
a7e5a84f1a
commit
d4ca673a5e
|
@ -1,7 +1,7 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="uft-8">
|
||||
<meta charset="utf-8">
|
||||
<script type="text/javascript" src="summ_of_numbers.js"></script>
|
||||
</head>
|
||||
<body onload="summ_of_numbers();">
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script type="text/javascript" src="task_1.js"></script>
|
||||
<title>JavaScript</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>JavaScript</h1>
|
||||
<p>
|
||||
<input type="button" value="add Entry" onclick="addTableRow();"/>
|
||||
<input type="text" id="textEntry" />
|
||||
</p>
|
||||
<table id="table">
|
||||
<tr>
|
||||
<td>Id</td>
|
||||
<td>Text</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,18 @@
|
|||
var counter = 0;
|
||||
|
||||
function addTableRow(){
|
||||
var table = document.getElementById("table");
|
||||
var tr = document.createElement("tr");
|
||||
|
||||
tr.appendChild(createTD(counter));
|
||||
var input = document.getElementById("textEntry");
|
||||
tr.appendChild(createTD(input.value));
|
||||
table.appendChild(tr);
|
||||
counter++;
|
||||
}
|
||||
|
||||
function createTD(text){
|
||||
var td = document.createElement("td");
|
||||
td.appendChild(document.createTextNode(text));
|
||||
return td;
|
||||
}
|
Reference in New Issue