<pre name= "code" class= "Java" >
drop-down box tags in jsp:
<s:select name= "SJX" id= "SJX" list= "sjxlist" listkey= "BM" listvalue= "MC" size= "cssstyle=" width:100%;height : 70px; border:0 "multiple=" true "></s:select>
<pre name= "code" class= "HTML" >
Multiple= "true" means that multiple selections are supported.
</pre><pre code_snippet_id= "487056" snippet_file_name= "blog_20141017_5_1612209" name= "code" class= " JavaScript >js How to flexibly create items under the Select tab:
<pre name= "Code" class= "javascript" >var Oselect = $ ("SJX"); <span style= "White-space:pre" ></span>// SJX is the ID of the SELECT tag on the HTML or JSP page, and if you use ExtJS, you can get the label var ooption = document.createelement ("OPTION") with Ext.getdom (' SJX '); <span style= "white-space:pre" ></span>//js create option sub-label under Select Tab OSelect.options.add (ooption);< Span style= "White-space:pre" ></span>//Add the new option sub-label to the Select tab ooption.value = "001"; <span style= " White-space:pre "></span>//content corresponds to value ooption.innerhtml =" Small Apple "; <span style=" White-space:pre "></ span>//Displays the contents of the drop-down box ... And so on
Note:js in this way, in a specific situation is more useful, such as: Here the request does not return a specific interface, that is, do not refresh the entire interface. Instead of using an AJAX asynchronous request to make some partial data requests, the following strut2 will not work.
<pre name= "code" class= "java" ><pre name= "code" class= "java" >for (...) {hashmap<string,object> map = new hashmap<string,objcet> () map.put ("BM", "001"); Map.put ("MC", "small apple"); Sjxlist.add (map);}
Another way, which is also very common: Use the STRUTS2 feature to define a list<object> variable in action (in this case, named: sjxlist), and set the set, get method.
With a HashMap object, add content, such as:
</pre> when returned to the interface, the "Little Apple" is displayed in the Select drop-down box in the interface.
<pre name= "code" class= "HTML" > The simplest way: Manually add option items to the Select tab directly on the JSP page
JS to create an HTML tag, add the default option under Select Value and text