好的,所以,我有一个列表,我想在用户从下拉列表中选择一个选项时显示一些文本,我想到如何为一个选项做出选择,但由于某些原因不能在组中工作好。
<select id="mySelect" name="values">
<option value=0>0</option>
<option value=1>1</option>
<option value=2>2</option>
</select>
我打算在选择每个选项时“打印”一些确定的文本,谢谢!
(对不起任何语法错误,西班牙语发言者)
答案 0 :(得分:0)
管理:
<script type="text/javascript">
function showstuff(element){
document.getElementById("una").style.display = element=="una"?"block":"none";
document.getElementById("dos").style.display = element=="dos"?"block":"none";
document.getElementById("tres").style.display = element=="tres"?"block":"none";
document.getElementById("cuatro").style.display = element=="cuatro"?"block":"none";
document.getElementById("cinco").style.display = element=="cinco"?"block":"none";
document.getElementById("seis").style.display = element=="seis"?"block":"none";
document.getElementById("siete").style.display = element=="siete"?"block":"none";
document.getElementById("ocho").style.display = element=="ocho"?"block":"none";
document.getElementById("nueve").style.display = element=="nueve"?"block":"none";
document.getElementById("diez").style.display = element=="diez"?"block":"none";
}
</script>
<select name="type" onchange="showstuff(this.value);">
<option value="una" selected>1</option>
<option value="dos">2</option>
<option value="tres">3</option>
<option value="cuatro">4</option>
<option value="cinco">5</option>
<option value="seis">6</option>
<option value="siete">7</option>
<option value="ocho">8</option>
<option value="nueve">9</option>
<option value="diez">10</option>
</select>
<div id="uno" style="display:none;">uno</div>
<div id="dos" style="display:none;">dos</div>
<div id="tres" style="display:none;">tres</div>
<div id="cuatro" style="display:none;">cuatro</div>
<div id="cinco" style="display:none;">cinco</div>
<div id="seis" style="display:none;">seis</div>
<div id="siete" style="display:none;">siete</div>
<div id="ocho" style="display:none;">ocho</div>
<div id="nueve" style="display:none;">nueve</div>
<div id="diez" style="display:none;">diez</div>
谢谢每一位:)