我試圖建立一個形式的條件式單選按鈕,其實我修改一些JavaScript我發現這裏看起來像這樣:JavaScript有條件 - 取消選中隱藏div中的單選按鈕?
function hideStuff(id) {
document.getElementById('flatDiv').style.display = 'none';
document.getElementById('salaryDiv').style.display = 'none';
}
function checkType(selectedType) {
if (selectedType == 'flat') {
document.getElementById('flatDiv').style.display = 'block';
document.getElementById('salaryDiv').style.display = 'none';
} else {
document.getElementById('flatDiv').style.display = 'none';
document.getElementById('salaryDiv').style.display = 'block';
}
}
和HTML是這樣的:
<input type="radio" name="Type" value="flat" onclick="checkType(this.value)" />Flat
<input type="radio" name="Type" value="salary" onclick="checkType(this.value)" />Salaray
<br />
<div id="salaryDiv" style="display:none;">Choose an option:
<input type="radio" name="salaryType" value="1x" />1x
<input type="radio" name="salaryType" value="2x" />2x
<input type="radio" name="salaryType" value="3x" />3x</div>
<div id="flatDiv" style="display:none;">Choose an option:
<input type="radio" name="flatType" value="$25,000" />$25,000
<input type="radio" name="flatType" value="$50,000" />$50,000</div>
這所有的作品,但如果有人點擊薪水,並選擇一個選項,然後改變主意,當他們點擊扁我希望搞清楚他們之前薪酬(和副VERS所作出的任何選擇a)我嘗試了一些不起作用的東西,所以我想我會問一個知道他們在做什麼的人。謝謝。
*什麼*你嘗試過不工作? – 2013-04-25 23:08:39