MP13 progress
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/html.html to edit this template
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Problem 3</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<label>Enter your name: <input id="nameInput"></label><br>
|
||||
<label>Enter your nickname:<input id="nickInput"></label><br>
|
||||
<label>Enter your email address: <input id="emailInput"></label><br>
|
||||
<label>Favorite movie: <input id="movieInput"></label><br>
|
||||
<label>Favorite book: <input id="bookInput"></label><br>
|
||||
<label>Favorite type of music: <input id="musicInput"></label><br>
|
||||
<label><input type="button" value="Submit" onclick="onClick();"></label><br>
|
||||
</body>
|
||||
<script>
|
||||
function onClick() {
|
||||
var userInput = {
|
||||
"name": "",
|
||||
"nickname": "",
|
||||
"email": "",
|
||||
"movie": "",
|
||||
"book": "",
|
||||
"music": ""
|
||||
};
|
||||
console.log(userInput[0]);
|
||||
let fields = ["nameInput", "nickInput", "emailInput", "movieInput", "bookInput", "musicInput"]
|
||||
let i = 0;
|
||||
for (const x in userInput) {
|
||||
userInput[x] = document.getElementById(fields[i++]).value;
|
||||
}
|
||||
console.log(userInput);
|
||||
let doc = "<p> Your information: <br>"
|
||||
for (const x in userInput) {
|
||||
doc += x + ": " +userInput[x] + "<br>";
|
||||
}
|
||||
doc += "</p>"
|
||||
document.write(doc);
|
||||
}
|
||||
</script>
|
||||
</html>
|
Reference in New Issue
Block a user