我有3個單選按鈕:額外的文本字段單選按鈕的JavaScript
- 津貼
- 學費
- 學校
如果我點擊津貼單選按鈕,它會打開列表中的ul
。現在
,單選按鈕津貼應該點擊單選按鈕學費
後關閉。當我點擊單選按鈕「不全額學費」,我應該在對貨幣的文本字段中鍵入但它關閉它。
我想在點擊「不是全部學費」後阻止它關閉,這樣我可以在Money文本框中輸入一個值。
如果我點擊學校的單選按鈕,它也會關閉。
我該如何得到這個工作?
function Allowance(select) {
if (select.value == 'Allowance') {
document.getElementById('allowance').style.display = "block";
} else {
document.getElementById('allowance').style.display = "none";
}
}
function Tuition(select) {
if (select.value == 'Tuition Fee') {
document.getElementById('tuition_fee').style.display = "block";
} else {
document.getElementById('tuition_fee').style.display = "none";
}
}
function Supply(select) {
if (select.value == 'School Supply') {
document.getElementById('school_supply').style.display = "block";
} else {
document.getElementById('school_supply').style.display = "none";
}
}
function Not_Full(select) {
if (select.value == 'Not Full') {
document.getElementById('Not_Full').style.display = "block";
} else {
document.getElementById('Not_Full').style.display = "none";
}
}
<input type="radio" name="ship_need" value="Allowance" id="test" onchange="Allowance(this)"> Allowance<br>
<div id="allowance" style="display: none;">
<ul>
<li>Food Allowance</li>
<li>Transportation Allowance</li>
</ul>
<label class="control-label">Money:</label>
<input type="text">
</div>
<input type="radio" name="ship_need" value="Tuition Fee" id="test" onchange="Tuition(this)"> Tution<br>
<div id="tuition_fee" style="display: none;">
<ul>
<li>Tuition Fee</li>
<input type="radio" name="test1" value="Full"> Full Tuition Fee<br>
<input type="radio" name="test1" value="Not Full" id="test" onchange="Not_Full(this)"> Not Full Tuition Fee<br>
</ul>
<div id="Not_Full" style="display: none;">
<label class="control-label">Money:</label>
<input type="text">
</div>
</div>
<input type="radio" name="ship_need" value="School Supply" id="test" onchange="Supply(this)"> School
<div id="school_supply" style="display: none;">
<ul>
<li>Books</li>
<li>Uniform</li>
</ul>
<label class="control-label">Money:</label>
<input type="text">
</div>
是的,先生其working.This是我真正want.Maybe你困惑的我的解釋,但你的修改是correct.Thank你了。 – Chee
樂意幫忙! :) –