So I have 3 text fields for user input and when text is entered and the "Register" button is pressed I wish for a new row featuring 3 cells (One for each field) to be created showing the text the user entered. But for the life of me I cannot figure out how to capture the input from the text field and insert it into the table cells. I've tried playing with document.getElementbyId and .innerHTML but it doesn't seem to work.
Right now "undefined" just appears in the cell.
<html>
<head>
<link type="text/css" rel = "stylesheet" href= "StudentStyle.css">
<title>Student Page</title>
<script type ="text/javascript">src = "registerBox.js" </script>
</head>
<body>
<div id = "all">
<h1 align="center">Student page of NAMEHERE</h1>
<h2 align="center">NAMEHERE's Class Schedule</h2>
<table id ="enrolled" align="center">
<tr id ="titleRow">
<th>Course</th>
<th>Course Number</th>
<th>Room</th>
</tr>
</table>
<div id = "registerBox">
<button onclick="addCourse()">Register</button>
<input type = "text" id = "courseName" placeholder= " Course Name">
<input type = "text" id = "courseNumber" placeholder = "Course Number">
<input type = "text" id = "Room" placeholder = "Room">
</div>
</div>
<script>
function addCourse() {
var i = 1 ;
var row = enrolled.insertRow(i);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var courseName;
document.getElementById("courseName").innerHTML = courseName;
cell1.innerHTML = courseName;
cell2.innerHTML = "test2";
cell3.innerHTML = "test3";
}
</script>
</body>
</html>