I posted a similar question yesterday and got some helpful responses but the problem I am having now is slightly different. When the user changes the type
on the UI, classes are added to the html elements (this simply adds a blue border around the element). I'm not receiving any error messages but it's just not doing anything.
document.querySelector(DOM.inputType).addEventListener('change', function() {
if (usersInput.type === "Health") {
document.querySelector('.input_type').className += " blue";
document.querySelector('.input_activity').className += " blue";
document.querySelector('.input_time').className += " blue";
document.querySelector('.input_end').className += " blue";
document.querySelector('.input_btn').className += " blue_btn";
}
});
.blue {
border: 2px solid blue !important;
}
.blue_btn {
color: blue;
}
<div class="input">
<select class="input_type" id="input_type" name="input_type" style="height:36px" placeholder="Type" required>
</select>
<input class="input_activity" type="text" name="activity" placeholder="What do you need to do?" size="60" style="height:32px" required>
<select class="input_time" name="Time" style="height:36px" required>
<option value="Start">Start</option>
</select>
<select class="input_end" name="end" style="height:36px" required>
<option value="End">End</option>
</select>
<input class="input_btn" type="button" value="Submit!">
</div>
Here is where usersInput
comes from:
var usersInput = UICtrl.getInput();
Here is where 'getInpu't comes from:
return {
getInput: function() {
return {
type: document.querySelector(DOMstrings.inputType).value,
activity: document.querySelector(DOMstrings.inputActivity).value,
startTime: document.querySelector(DOMstrings.inputStart).value,
endTime: document.querySelector(DOMstrings.inputEnd).value
};
},
},
These are the options to select from the 'type' drop down menu:
<select class="input_type" id="input_type" name="input_type" style="height:36px" placeholder="Type" required>
<option value="">Type</option>
<option value="health">Health</option>
<option value="work">Work</option>
<option value="leisure">Leisure</option>
</select>
Please note, I have checked similar questions on the forum but none that I have found have really answered my question. Thanks in advance for your support!