-
-
Save ggagosh/47e24c52ab6354419d4b318c94b5bba2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
table { | |
font-family: arial, sans-serif; | |
border-collapse: collapse; | |
width: 100%; | |
} | |
td, th { | |
border: 1px solid #dddddd; | |
text-align: left; | |
padding: 8px; | |
} | |
tr:nth-child(even) { | |
background-color: #dddddd; | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Hello</h1> | |
<form name="myform" onsubmit="return validateMyForm();"> | |
<input id="fname" placeholder="First Name" type="text" name="fname"> | |
<input type="submit" name="Submit" value="submit"> | |
</form> | |
<table> | |
<thead> | |
<th>First Name</th> | |
</thead> | |
<tbody id="MaBody"> | |
<tr> | |
<td>Giorgi</td> | |
</tr> | |
</tbody> | |
</table> | |
<script src="code.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validateMyForm() | |
{ | |
var nameValue = document.getElementById("fname").value; | |
var element = document.getElementById("MaBody"); | |
var newElement = '<tr><td>'+ nameValue + '</td></tr>' | |
element.insertAdjacentHTML( 'beforeend', newElement ) | |
document.getElementById("fname").value = ''; | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment