0

have a dropdown where i have set of account numbers and an option of "Other". user can select any account or they can user "Other" option to enter a new account. I have the code like this:

      <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>             

--- Togglefield function is as below

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

My question is, 1) when I select other, the text box displays- good. But how to assign the value to accountNumber ? when I click submit, it is not recognizing getting invalid account number. 2) When the page refreshes with validation errors, how do I retain value "other" and the text box with the number that is entered? appreciate your input on this.

RMa
  • 111
  • 2
  • 7
  • 18

1 Answers1

0

You are mixing html fields and struts fields. I think for your input field you need to use:

<html:text property="accountNumber" />
kfox
  • 1,176
  • 13
  • 16
  • i can use – RMa Feb 12 '11 at 01:05
  • Check out http://stackoverflow.com/questions/2475296/how-to-use-javascript-to-include-struts-html-tag I think it's trying to do something similar. I think you need to use styleId within the html:text tag. I don't have a struts environment currently set up, so I can't easily test this out. Give it a try though to see if it will work. – kfox Feb 14 '11 at 05:08