我有多個下拉菜單,但當用戶嘗試選擇多個選項時,屏幕上只顯示1。另外,我希望選擇顯示在下拉菜單旁邊,但它目前顯示在下。這是代碼。謝謝!如何使用用戶輸入在屏幕上顯示多個選擇?
<script type="text/javascript">
function showfield(name){
//------------------------------------------------------------
//If chosen show user input
//------------------------------------------------------------
if(name=='GT')document.getElementById('div1').innerHTML='Greater Than: <input type="text" name="GreaterThan" />';
if(name=='GE')document.getElementById('div2').innerHTML='Greater Equal to: <input type="text" name="GreaterEqualTo" />';
if(name=='LT')document.getElementById('div3').innerHTML='Less Than: <input type="text" name="LessThan" />';
if(name=='LE')document.getElementById('div4').innerHTML='Less Than Equal to: <input type="text" name="LessThanEqualTo" />';
if(name=='EQ')document.getElementById('div5').innerHTML='Equal to: <input type="text" name="EqualTo" />';
if(name=='B1')document.getElementById('div6').innerHTML='Between 1: <input type="text" name="Between1" />';
if(name=='B2')document.getElementById('div7').innerHTML='Between 2: <input type="text" name="Between2" />';
if(name=='NE')document.getElementById('div8').innerHTML='Not Equal to: <input type="text" name="NotEqualTo" />';
//------------------------------------------------------------
//If not selected dont show user input
//------------------------------------------------------------
if(name!='GT')document.getElementById('div1').innerHTML='';
if(name!='GE')document.getElementById('div2').innerHTML='';
if(name!='LT')document.getElementById('div3').innerHTML='';
if(name!='LE')document.getElementById('div4').innerHTML='';
if(name!='EQ')document.getElementById('div5').innerHTML='';
if(name!='B1')document.getElementById('div6').innerHTML='';
if(name!='B2')document.getElementById('div7').innerHTML='';
if(name!='NE')document.getElementById('div8').innerHTML='';
}
</script>
<select name="ChosenQualifiers[]" onchange="showfield(this.options[this.selectedIndex].value)" id="qual" multiple >
<option selected='selected'> Choose a Qualifier </option>
<option value='GT'> Greater Than </option>
<option value='GE'> Greater Equal to </option>
<option value='LT'> Less Than </option>
<option value='LE'> Less Than Equal to </option>
<option value='EQ'> Equal to </option>
<option value='B1'> B1 </option>
<option value='B2'> B2 </option>
<option value='NE'> Not Equal to </option>
</select>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<div id="div4"></div>
<div id="div5"></div>
<div id="div6"></div>
<div id="div7"></div>
<div id="div8"></div>
你的第二個巨大的塊標註的評論'如果沒有選擇不顯示用戶輸入'就是爲什麼一次只更改一個div。 – Gavin