Skip to content

Class updates #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions about.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="form.css">
<title>About</title>
</head>
<body>

</body>
</html>
44 changes: 44 additions & 0 deletions dom.js
@@ -0,0 +1,44 @@
function submitForm(event) {
event.preventDefault();
var formData = document.forms[0].elements;

var contactData = {
firstName: formData.firstName.value,
lastName: formData.lastName.value,
email: formData.email.value,
termsAccepted: formData.terms.value,
submittedDate: new Date()
};

console.log(contactData);
documentMethods();
}

function documentMethods() {
var firstNameInput = document.getElementById('first-name');
var inputTags = document.getElementsByTagName('input');
var inputGroups = document.getElementsByClassName('input-group');

//attributes
firstNameInput.name = 'newName';
firstNameInput.hidden = true;

//modify styles
inputTags[1].style.border = "2px solid red";
inputTags[2].style.margin = "30px";
}

function showAbout() {
document.getElementById('home').hidden = true;
document.getElementById('about').hidden = false;
document.getElementsByTagName('button')[0].setAttribute('class', 'submit-btn');
}

function showHome() {
document.getElementById('home').hidden = false;
document.getElementById('about').hidden = true;

//document.createTextNode
document.createElement("h1").innerText = "NAVIGATED HOME";
document.appendChild();
}
18 changes: 18 additions & 0 deletions form.css
@@ -0,0 +1,18 @@
.submit-btn {
padding: 10px;
color: white;
background-color: blue;
border-radius: 5px;
}

.submit-btn:hover {
opacity: 0.8;
}

.input-group {
margin: 10px 0 10px 0;
}

.contact-form {
max-width: 500px;
}
45 changes: 45 additions & 0 deletions index.html
@@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="form.css">
<title>Document Object Model</title>
</head>
<body>
<div id="home">
<button onclick="showAbout()">About</button>
<h1>Forms and Capturing Data</h1>

<form class="contact-form">
<fieldset>
<legend>Contact Us</legend>
<div class="input-group">
<label for="first-name">First Name</label>
<input id="first-name" type="text" name="firstName">
</div>
<div class="input-group">
<label for="last-name">Last Name</label>
<input id="last-name" type="text" name="lastName">
</div>
<div class="input-group">
<label for="email">Email Address</label>
<input id="email" type="email" name="email">
</div>
<div class="input-group">
<label for="terms">Agree to terms</label>
<input id="terms" type="checkbox" name="terms">
</div>
<!-- <input class="submit-btn" type="submit" value="Submit" onclick="submitForm()"> -->
<button class="submit-btn" onclick="submitForm(event)">Submit</button>
</fieldset>
</form>
</div>

<div id="about" hidden>
<button onclick="showHome()">Home</button>
<h1>About</h1>
<p>Welcome to our About page! Info and info and info</p>
</div>

<script src="dom.js"></script>
</body>
</html>