Вы также можете использовать IHtmlHelper.GetEnumSelectList.
// Summary:
// Returns a select list for the given TEnum.
//
// Type parameters:
// TEnum:
// Type to generate a select list for.
//
// Returns:
// An System.Collections.Generic.IEnumerable`1 containing the select list for the
// given TEnum.
//
// Exceptions:
// T:System.ArgumentException:
// Thrown if TEnum is not an System.Enum or if it has a System.FlagsAttribute.
IEnumerable<SelectListItem> GetEnumSelectList<TEnum>() where TEnum : struct;
Во-первых, имя всех переключателей должно быть одинаковым. Таким образом, он может выбрать по одному. второй div, который вы отображаете, одновременно скрывает другой div.
function show1() {
document.getElementById('div1').style.display = 'none';
document.getElementById('div2').style.display = 'none';
}
function show2() {
document.getElementById('div2').style.display = 'none';
document.getElementById('div1').style.display = 'block';
}
function show3() {
document.getElementById('div1').style.display = 'none';
document.getElementById('div2').style.display = 'block';
}
body {
font-family: arial;
}
.hide {
display: none;
}
p {
font-weight: bold;
}
<p>Leave</p>
<input type="radio" name="tab" value="igotnone" onclick="show1();" /> Full Day
<input type="radio" name="tab" value="igottwo" onclick="show2();" /> From
<input type="radio" name="tab" value="igottwo" onclick="show3();" /> To
<div id="div1" class="hide">
<hr>
<p>From Which Half Session You Are Not Available???</p>
<input type="radio" value="Yes" name="one"> First Session
<input type="radio" value="Yes" name="one"> Second Session
</div>
<div id="div2" class="hide">
<hr>
<p>To Which Half Session You Are Not Available???</p>
<input type="radio" value="Yes" name="two"> First Session
<input type="radio" value="Yes" name="two"> Second Session
</div>
Вы можете заключить две div
в одну div
и показать / скрыть только это.
Кроме того, переключатели должны иметь одно и то же значение name
, чтобы пользователи могли выбирать только один параметр за раз.
function show1() {
document.getElementById('divs').style.display = 'none';
}
function show2() {
document.getElementById('divs').style.display = 'block';
}
function show3() {
document.getElementById('divs').style.display = 'block';
}
body {
font-family: arial;
}
.hide {
display: none;
}
p {
font-weight: bold;
}
<p>Leave</p>
<input type="radio" name="tab" value="igotnone" onclick="show1();" /> Full Day
<input type="radio" name="tab" value="igottwo" onclick="show2();" /> From
<input type="radio" name="tab" value="igottwo" onclick="show3();" /> To
<div id="divs" class="hide">
<div id="div1">
<hr>
<p>From Which Half Session You Are Not Available???</p>
<input type="radio" value="Yes" name="one"> First Session
<input type="radio" value="Yes" name="one"> Second Session
</div>
<div id="div2">
<hr>
<p>To Which Half Session You Are Not Available???</p>
<input type="radio" value="Yes" name="two"> First Session
<input type="radio" value="Yes" name="two"> Second Session
</div>
</div>