有这样一道题:一个文本框,用户输入若干关键字,关键字用空格或者逗号隔开。输入完成后,点击button按钮,使用select控件显示用户输入的每一个关键字。 没看懂啥意思,难道意思是把文本框里的值传入select下拉框的每一项???不懂啊!!求本题完整代码。。
<script type="text/javascript">function test(){ the1=document.getElementById("1"); theArray=the1.value.split(","); the2=document.getElementById("2"); the2.options.length=0; for(i=0;i<theArray.length;i++){ the2.options.add(new Option(theArray[i])); }}</script><input id="1" type="text" /><input type="button" onclick="test()" value="提交" /><br /><select id="2"></select>