Skip to content

Commit

Permalink
Add increment/decrement buttons to time
Browse files Browse the repository at this point in the history
  • Loading branch information
jiannazzone committed Nov 9, 2023
1 parent e6ad7f2 commit ed756e4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
8 changes: 6 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ <h1 id="title">HALL PASS</h1>
<div><input class="card" id="student-name-input" placeholder="Student Name"></div>
<div><input class="card" id="destination-input" placeholder="Destination"></div>
<div class="card">
<input name="duration" id="duration-input" type="range" value="5" min="5" max="45" step="5" onchange="updateDuration()">
<div id="duration-display">5 minutes</div>
<div id="duration-display">
<span id="duration-value">5</span>
<span>minutes</span>
</div>
<button class="duration-button card" id="duration-down" onclick="updateDuration('decrease')">- 5</button>
<button class="duration-button card" id="duration-up" onclick="updateDuration('increase')">+ 5</button>
</div>

</div>
Expand Down
16 changes: 11 additions & 5 deletions scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ setInterval(function () {
// END UNIVERSAL METHODS

// FORM.HTML METHODS
function updateDuration() {
const duration = document.getElementById('duration-input').value;
const durationDisplay = document.getElementById('duration-display').innerHTML = duration + ' minutes';
let duration = 5;
function updateDuration(action) {
let increment = 5;
if (action == "increase" && duration < 45) {
duration += increment;
} else if (action == "decrease" && duration > 5) {
duration -= increment;
}
document.getElementById('duration-value').innerHTML = duration;
}

function requestPass() {
const studentName = document.getElementById('student-name-input').value;
const studentDestination = document.getElementById('destination-input').value;
const studentDuration = document.getElementById('duration-input').value;
const studentDuration = document.getElementById('duration-value').innerHTML;


// Check for invalid inputs
if (studentName == '' | studentDestination == '' | studentDuration == '') {
alert('Please complete all three forms before requesting a pass.');
alert('Please complete both fields before requesting a pass.');
return;
}

Expand Down
7 changes: 6 additions & 1 deletion styles/form.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ button {

input, button {
font-family: 'DM Serif Display';
font-size: 0.5rem;
color: navy;
}

.duration-button {
font-size: 1rem;
font-weight: bolder;
}

video {
Expand Down

0 comments on commit ed756e4

Please sign in to comment.