-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds slider with comment text and scale number box
- Loading branch information
Showing
3 changed files
with
23 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,17 @@ | ||
/* eslint-disable */ | ||
var scales = document.querySelectorAll('input[type=range]') | ||
|
||
// we need to use an array of comments from the database - this one is for testing only | ||
const test = ['Comment for 1', '', 'Comment for 3', 'Comment for 4', 'Comment for 5']; | ||
|
||
scales.forEach( (scale) => { | ||
scale.addEventListener('click', function(){ | ||
var currentScale = `${this.id}`; | ||
var commentBoxId = `result${currentScale.slice(currentScale.indexOf('-'))}`; | ||
|
||
console.log(`the current scale is: ${currentScale}`); | ||
console.log(`the comment box associated with the current scale has an id of ${commentBoxId}`); | ||
const test = ['No pain', '', '', '', '4 means I take some pain medication', '', '', '', 'Can\'t focus on anything but my pain', '', '']; | ||
|
||
var commentBox = document.getElementById('commentBoxId'); //Not working | ||
|
||
scales.forEach((scale) => { | ||
scale.addEventListener('change', function () { | ||
var currentScaleId = `${this.id}`; | ||
var commentBoxId = `result${currentScaleId.slice(currentScaleId.indexOf('-'))}`; | ||
var scaleNumberId = `${this.id}-number`; | ||
var scaleNumber = document.querySelector(`#${scaleNumberId}`); | ||
var commentBox = document.querySelector(`#${commentBoxId}`); | ||
|
||
|
||
//commentBox.innerHTML = test[`${this.value}`]; | ||
|
||
// result.innerHTML = `the scale is on ${this.value} and the comment is ${arr[this.value-1]}`; | ||
scaleNumber.textContent = `${this.value}`; | ||
commentBox.textContent = test[this.value] === '' ? "Any comments you've saved will appear here as you move the scale" : `Hint: ${test[this.value]}` | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters