我用下面的HTML代碼顯示選項:如何從'select class'標籤中選擇一個選項後才顯示輸入選項?
<select class="form-control input-lg" style="text-align:center">
<option value="type">-- Select a Type --</option>
<option value="student">Student</option>
<option value="company">Company</option>
</select>
現在假設我想要顯示的div標籤內輸入框列表(如下圖所示),只有當我選擇的選項,學生和獨立公司根據用戶選擇的輸入選項列表。下面的輸入框是學生的選擇:
<div id="divina">
<input class="form-control input-lg" name="name" placeholder="Full Name" type="text" >
<input class="form-control input-lg" name="usn" placeholder="USN" type="text">
<select class="form-control input-lg" name="branch">
<option value="Month">-- Select branch --</option>
<option value="Month">Computer Science & Engineering</option>
<option value="Month">Information Science & Engineering</option>
<option value="Month">Electronics & Communication Engineering</option>
<option value="Month">Electrical & Electronics Engineering</option>
<option value="Month">Mechanical Engineering</option>
<option value="Month">Civil Engineering</option>
<option value="Month">MBA</option>
<option value="Month">MCA</option>
</select>
<input class="form-control input-lg" name="contact" placeholder="Contact No." type="text">
<input class="form-control input-lg" name="email" placeholder="E-mail" type="email">
<input class="form-control input-lg" name="password" placeholder="Password" type="password">
</div>
我使用下面的JavaScript頭標記:
JS:
function show(that){
if(that.value=="student"){
document.getElementById("divina").style.display = "block";
}
else{
document.getElementById("divina").style.display = "none";
}
}
嗯,我已經嘗試了很多,但它根本不工作,任何輸入或建議將不勝感激!
從哪裏調用'show'方法? – gurvinder372
請確認!你的意思是你有兩個div塊內容,分別爲學生和另一個公司。現在你想在選擇學生時顯示學生塊,選擇公司時顯示公司塊。是這樣嗎? – ameenulla0007
@ ameenulla0007是的,它是如此 –