开发者

"other" option in dropdown menu and setting values

开发者 https://www.devze.com 2023-02-10 10:29 出处:网络
I ha开发者_开发百科ve a comboboxwith an option"other". user can select an entry from the list or select option "other". if they select "other"a text box will disply below

I ha开发者_开发百科ve a combobox with an option "other". user can select an entry from the list or select option "other". if they select "other" a text box will disply below to enter a new account number. see the code below:

              <td>1. Account Number<span class="bodyCopy"><font color="#ff0000"> * </font></span>: 
        <html:select name="reDataForm" property="Member.accountNumber"  styleClass="formContent" 
          style="width:80px" onchange="showfield(this.options[this.selectedIndex].value)">
         <html:options collection="<%= WorkConstants.NewDropdowns.PACCT %>" property="value" labelProperty="label" styleClass="formContent"/>
        
         </html:select>

    
         <div id="div1"></div>

It works fine. But when the page refreshes, the text box disappears as no code to keep it there. 1)how do I keep the text box if the use was selected "Other" and entered a new account number in the text box ? OR if we can add the text box value into the dropdown list, that will also work. 2) Also how to set the text box value into the same variable Member.accountNumber ?

please help me !!!!


  1. Use a little bit of javascript on an onLoad event to check if other is selected, and display the text box
  2. You can't submit the value as the same name as the select box. instead, submit as a second name and process accordingly in your ActionForm on the serverside.
0

精彩评论

暂无评论...
验证码 换一张
取 消