/**
* @author zhou2003737
* @date 2014/09/25 16:39
*/
window.onload = function(){
//获取文本框对象
var searchText = document.getElementById("searchText");
//获取提交button对象
var action = document.getElementById("action");
//获取要增加到的下拉列表对象
var selections = document.getElementById("selections");
//点击提交的时候执行的方法
action.onclick = function(){
//如果文本框对象中值不为空
if(searchText.value ){
//根据文本框中的值循环5次
for(var i =5;i>0;i--){
//设置下拉列表中的值的属性
var option = document.createElement("option");
option.value = searchText.value + i;
option.text= searchText.value+i;
//将option增加到下拉列表中。
selections.options.add(option);
}
}
}
}
//思路如上。你可以将点击时将文本框中值传到后台,后台返回数据后,在将数据存入下拉列表对象中。