将下拉列表框中的数据添加到文本框中

Wednesday May 23, 2007

下拉列表框中的数据是从字典表中取得的, 实现方法 在 这里
这次是采用js来实现的,代码如下

      function atSub()
{
    var index_s =document.add.test.selectedIndex;
    var content = document.add.test.options[index_s].value;
     document.add.member.value+= content + "   ";
}

页面代码如下

<tr>
<td class='small' width="14%" bgcolor="#D8EBF5">
   <div align="center">成员:</div>
</td>
<td colspan="3" bgcolor="#D8EBF5" class='small'>
<input type="text" name="member" id="member" size="76.5">
    <select style="width: 160; height: 23" 
        onChange="javascript:atSub();" name="test">
	<option value="">选择成员	</option>
		<%
                     Vector mm = UserInfo.getAllUsers();
                         for(int i=0;i<mm.size();i++){
                             UserInfo mmall = (UserInfo)mm.get(i);
		%>
		<option value="<%=mmall.getUserName()%>">
	                <%=mmall.getUserName()%>
		</option>
               <%}%>
    </select>
</td>
</tr>

1 Comment

  1. Thank you for creating a blog. I hope you will take frequent moments to let us in the wide world know what you’re doing with your time now that you’ve become famous — and I hope you became richer, too!

Leave a reply