测试过了,希望能帮你
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<html:html lang="true">
  <head>
    <html:base />   
    <title>Test.jsp</title>
    <script type="text/javascript">
     function sele_fun(option_value){
     var value;
     if(option_value=="ByID"){
     value="<input type=text style='width:200px' value='^_^'>";
     }else if(option_value=="ByIdentity"){
     value="<select><option>^_^</option><option>^_^</option><option>^_^</option></select>";    
     }else{
     value="";
     }
     document.getElementById("op").innerHTML=value;
     }
    </script>
  </head>  
  <body>
<html:select property="sel" onchange="sele_fun(this.value)">
<option value="...">...</option>
<option value="ByID">ByID</option>
<option value="ByIdentity">ByIdentity</option>
</html:select>
<P>
<div id="op"></div>
</body>
</html:html>

解决方案 »

  1.   

    可以在页面上同时放text框和下拉框,通过js控制这两个的display属性,显示或不显示
    <html:select property="p1" onchange="chg(this.value)">
          //这里你可以添入byID和ByIdentity的选项
    </html:select>
    <html:text propert="p2" style="display:none"/>
    <html:select property="p3" style="display:none">
          //这里设置option选项
    </html:select>
    <script>
    function chg(flag){
      if(flag=='byId'){
         formname.p2.style.display='';
         formname.p3.style.display='none';
       }
       if(flag=='ByIdentity'){
         formname.p2.style.display='none';
         formname.p3.style.display='';
       }
    }
    </script>我上面用的p1、p2、p3是指你Form里面的属性
    formname是指你的Action所对应formbean名
      

  2.   

    to:othella
    "formname是指你的Action所对应formbean名"
    对应的哪个formbean啊,是对应的form类名?还是struts-config.xml中<action name="">的name?还是在action类中定义的formbean的对象名?我都试过了,都不行啊
      

  3.   

    谢谢lx978,script中可以用struts标签吗
      

  4.   

    to lx978
    我运行你的代码为什么会报错呢
    javax.servlet.ServletException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
      

  5.   

    script中不能用struts标签的,所以我用的是普通html语言啊^_^
      

  6.   

    不能用STRUTS标签那怎么在action中调用数据能
      

  7.   

    调用数据你还是照旧用request.getParameter()方法来取得文本框或是下拉框的value,注意如果是select的话,最好用一个hidden来接受select的值,然后在action中就去取hidden的值就好了