我有一個下拉列表,其中有其他選項,當選擇其他選項時出現一個新的字段,我們可以輸入文本指定其他,BUt文本填充時我沒有得到填補了該領域的數據我只得到其他在下拉字段中插入的文本沒有反映
HTML:
<html>
<head>
<script type="text/javascript">
function showfield(name){
if(name=='Other')document.getElementById('div1').innerHTML='Other: <input type="text" name="other" />';
else document.getElementById('div1').innerHTML='';
}
</script>
</head>
<body>
<select name="drop" id="drop" onchange="showfield(this.options[this.selectedIndex].value)">
<option selected="selected">Please select ...</option>
<option value="car">car</option>
<option value="bike">bike</option>
<option value="Other">Other</option>
</select>
<div id="div1"></div>
</body>
</html>
而如何把一個幫助文本,當我們插入時,另一個是即將到來的新的文本框裏面的數據將消失選擇。
在此先感謝。
使用jQuery是這樣的事情更容易爲工作 – RRR