I'm trying to add a row to a table with pre-existing values. On each row there is an "Edit" button that doesn't do anything (by design). I also have a prompt where the user would input their name, email, and phone number and that would be added to the table above. Everything works but I think I'm missing something in my .js file. What am I missing?
let btnAdd = document.querySelector('button');
let table = document.querySelector('table');
let nameInput = document.querySelector('#name');
let numberInput = document.querySelector('#number');
let emailInput = document.querySelector('#email');
/* btnAdd.addEventListener('click', () =>{
let name = nameInput.value;
let number = numberInput.value;
let email = emailInput.value;
let template = `
<tr>
<td>${name}</td>
<td>${number}</td>
<td>${email}</td>
<td><input type ="button" value="Edit" onclick="javascript:void(0);" </td>
<td><input type ="button" value="Add New Contact" onclick="script.js();" </td>
</tr>
`;
table.innerHTML += template;
})
}*/
function demoClick ()
{
alert
(
"Script Loaded"
);
}
<html>
<head>
<title>Stars in the HollyWoo Sky</title>
<link href = "style.css" rel="stylesheet" type="text/css">
<script type = "text/javascript" src= "script.js">
</script>
</head>
<body>
<img class= "img-horse" src = "hollywoo.jpg" alt="Sad Horse Man">
<div class = "container">
<div id="data">
<h3>Add your info to recieve notifications!</h3>
<input type = "text" id="name" placeholder="Enter Name">
<input type = "text" id="number" placeholder="Enter Phone Number">
<input type = "text" id="email" placeholder="Enter Email Address">
<input type ="button" value="Add New Contact" onclick="demoClick();"></td>
</div>
<table class= "content-table" id="ContactList">
<thead>
<h2>Secretariat Mailing List</h2>
<tr>
<th>Contact Name</th>
<th>Contact Number</th>
<th>Contact Email</th>
<th>Contact Action</th>
</tr>
</thead>
<tbody>
<tr>
<td>Bojack Horseman</td>
<td>323-902-1992</td>
<td>SecretariatRulez96@hotmail.com</td>
<td><input type ="button" value="Edit" onclick="javascript:void(0);" /></td>
</tr>
<tr>
<td>Diane Nguyen</td>
<td>323- 319-1980</td>
<td>TotallyNotDiane@gmail.com</td>
<td><input type ="button" value="Edit" onclick="javascript:void(0);" /></td>
</tr>
<tr>
<td>Todd Chavez</td>
<td>323-248- 4156</td>
<td>DizneyWorld@bonzibuddi.net</td>
<td><input type ="button" value="Edit" onclick="javascript:void(0);" /></td>
</tr>
</tbody>
</table>
</div>
</body>
</html>