Is there a way to disable one function with another in JavaScript? I have a form that shows additional coursework inputs only if the user has completed extra work, but I want to add a failsafe in case they change their mind.
I need assistance in writing a failsafe function that checks if the first function has been triggered and then disables it.
CodePen: http://codepen.io/theodore_steiner/pen/ORzpQQ
function hideCourseWork() {
var otherEducationHistory = document.getElementById("otherEducationHistory");
otherEducationHistory.style.display = "none";
if (otherEducationHistory.style.display == "none") {
var noAdditionalCourseWork = document.getElementById("noAdditionalCourseWork");
var checkNo = document.getElementById("checkNo");
var undo = document.getElementById("undoNoAdditionalCourseWork");
noAdditionalCourseWork.style.top = "-48px";
checkNo.style.top = "-65px";
undo.style.top = "-65px";
undo.style.top = "-63px";
}
};
<div class="input-group" id="other-education">
<p class="subtitleDirection">Please list in chronological order, any additional cources beyond the degree(s) listed above, including any Ministry of Education Courses. If you have not completed any additional course work, please indicate.</p>
<div class="clearFix"></div>
<label id="otherEducation">Additional Courses*</label>
<div id="otherEducationHistory">
<input type="text" class="three-lines" name="otherUniversity_1" placeholder="Institution" onblur="this.placeholder='Institution'" onfocus="this.placeholder=''" />
<input type="text" class="three-lines" name="otherDegree_1" placeholder="Degree/Diploma" onblur="this.placeholder='Degree/Diploma'" />
<input type="date" class="three-lines" name="otherEducationYear_1" />
<input type="button" value="+" onclick=addOtherEducation() />
</div>
<!--end of otherEducationHistory div-->
<div class="clearFix"></div>
</div>
<!--end of other-education div-->
<p id="noAdditionalCourseWork">I have not completed any additional course work.</p>
<input type="radio" name="checkNo" id="checkNo" onclick="hideCourseWork()" />
<br />
<p id="undoNoAdditionalCourseWork" onclick="reAddCourseWork()">(Undo).</p>