我想知道我是如何使用另一個功能禁用一個功能的。我有一個表格要求額外的課程作業,但如果用戶沒有完成任何額外工作,則隱藏輸入。如果他們刪除了一組輸入並改變了他們的想法,我想進行失敗保護。使用另一個功能禁用一個功能 - 香草JS
我需要幫助的是編寫故障安全功能,檢查:如果功能1發生,禁用它。
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>
我真的困惑的問題是什麼嗎?我們是不是隻是隱藏和顯示基於無線電價值的HTML元素? –
是的。然而,我想更進一步,並學習如何通過函數來實現它......僅僅爲了這個例子以及未來的知識。 –
爲什麼過度設計工作?我從來沒有在我的整個職業生涯中'禁用'一個功能 –