java - How to display a text field based on s:select struts 2 -


i have jsp file include these lines:

<s:select list="list" name="message" id="selectmsg"></s:select> <div id="txtmessage" style="display:none">    <h3>       <span id="txtmessage" style="margin-left: 230px">           message: <s:textarea name="message" placeholder="message"/>       </span>    </h3> </div> 

action:

public string warn() throws exception {     warndao dao = new warndao();      accountdao accdao = new accountdao();     acc = accdao.getaccountbyusername(username);      list<warningmessage> warningmessage = dao.showmsg();     list = new arraylist<string>();     (warningmessage warningmessage1 : warningmessage) {         list.add(warningmessage1.getmessage());     }     list.add("other");       warning_msg_dao wmdao = new warning_msg_dao();     wm = wmdao.getbymessage(message);      dateformat dateformat = new simpledateformat("hh:mm dd/mm/yyyy");     date date = new date();     system.out.println(dateformat.format(date));     warningaccount warningacc = new warningaccount();     warningacc.setwarnedaccount(acc);     warningacc.setmessage(message);     warningacc.setday(date);      dao.warn(warningacc);     return "success"; } 

in s:select include option "other". when user choose "other" text area display , allow user input own message. there solution?

function toggleother(val){      document.getelementbyid("other").style.display = (val=="other") ? "block" : "none";  }
<select onchange="toggleother(this.value);">      <option value="foo"  >________ foo ________</option>      <option value="bar"  >________ bar ________</option>      <option value="other">_______ other ______</option>  </select>  <div id="other" style="display: none;">          <textarea>i'm visible when choosing other</textarea>  </div>


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -