js get data from form
const form = document.querySelector('form');
const data = new FormData(form);
js get data from form
const form = document.querySelector('form');
const data = new FormData(form);
form data display javascript
// Form Details display in plain JAVASCRIPT
// HTML
<body>
<form action="#">
<input
type="text"
id="myName"
placeholder="enter your name"
/><br /><br />
<input
type="text"
id="myNumber"
placeholder="enter your Number"
/><br /><br />
</form>
<input type="submit" onclick="buttonSubmit()" />
<table id="user-table">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody id="user-table-data"></tbody>
</table>
</body>
// javascript
<script>
let userList = [];
const buttonSubmit = () => {
let nameInput = document.getElementById("myName").value;
let numberInput = document.getElementById("myNumber").value;
let myData = {
name: nameInput,
number: numberInput,
};
userList.push(myData);
localStorage.setItem("userData", JSON.stringify(userList));
tableDataPopulate();
};
const tableDataPopulate = () => {
const allData = localStorage.getItem("userData");
const table = document.getElementById("user-table-data");
let userHtml = "";
userList.forEach((user, i) => {
userHtml += `<tr><td>${user.name}</td><td>${user.number}</td></tr>`;
});
table.innerHTML = userHtml;
};
</script>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us