Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 当用户选择";其他";刷新页面时如何分配值和保留值_Java_Jsp_Struts - Fatal编程技术网

Java 当用户选择";其他";刷新页面时如何分配值和保留值

Java 当用户选择";其他";刷新页面时如何分配值和保留值,java,jsp,struts,Java,Jsp,Struts,有一个下拉列表,其中我有一组帐号和一个“其他”选项。用户可以选择任何帐户,也可以使用“其他”选项输入新帐户。我有这样的代码: <td>1. Member Account Number<span class="bodyCopy"><font color="#ff0000"> * </font></span>: <html:select name="DataForm" property="accountN

有一个下拉列表,其中我有一组帐号和一个“其他”选项。用户可以选择任何帐户,也可以使用“其他”选项输入新帐户。我有这样的代码:

      <td>1. Member Account Number<span class="bodyCopy"><font color="#ff0000"> * </font></span>: 
        <html:select name="DataForm" property="accountNumber"  styleClass="formContent"  style="width:80px" onchange="toggleField(this.value);">
         <html:options collection="<%= WorkConstants.TEST1 %>" property="value" labelProperty="label" styleClass="formContent"/>
         <option value="Other">Other </option> 
          </html:select>
         <input type="text" id="Other" value="accountNumber" name="accountNumber" style="display:none;" maxlength="9" size="9" >    
        </td>             
1。会员帐号*:
另外
---Togglefield函数如下所示

       <script type="text/javascript">
     function toggleField(value) 
    {var a = document.getElementById('Other');
    (value == 'Other')? a.style.display = 'block' : a.style.display = 'none';}

函数切换字段(值)
{var a=document.getElementById('Other');
(值='Other')?a.style.display='block':a.style.display='none';}
我的问题是,, 1) 选择“其他”时,文本框将显示-good。但是如何将值分配给accountNumber呢?当我单击“提交”时,它无法识别获得的无效帐号。
2) 当页面刷新时出现验证错误,如何保留值“other”和带有输入数字的文本框?感谢您在这方面的投入。

您正在混合html字段和struts字段。我认为您的输入字段需要使用:

<html:text property="accountNumber" />

我可以使用Check out,我想它也在尝试做类似的事情。我认为您需要在html:text标记中使用styleId。我目前没有设置struts环境,因此无法轻松测试。试一试看它是否管用。