<pre name="code" class="java">
Pull-down box tags in jsp:
<s:select name="sjx" list="sjxList" listKey="BM" listValue="MC" size="20" cssStyle="width:100%;height:70px; border:0" multiple="true"></s:select>
<pre name="code" class="html">
multiple="true" means to support multiple selections.
</pre><pre code_snippet_ snippet_file_name="blog_20141017_5_1612209" name="code" class="javascript">
How to flexibly create items under the select tag in js:
<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. If you use Extjs, you can use ('sjx') to get the tag
var oOption = ("OPTION");<span style="white-space:pre"> </span>// create OPTION subtitles under the select tag in js
(oOption);<span style="white-space:pre"> </span>//Add the newly created OPTION sub-label to the select tag
= "001";<span style="white-space:pre"> </span>//The value corresponding to the content
="Little Apple";<span style="white-space:pre"> </span>//The content of the drop-down box displayed
...and so on
Note: This method in js is more useful in specific occasions, such as: the request here does not return a specific interface, that is, it does not refresh the entire interface. Instead, use Ajax method to make some local data requests, then the following strut2 method will be invalid.
<pre name="code" class="java"><pre name="code" class="java">for(...){
HashMap<String,Object> map = new HashMap<String,Objcet>();
("BM","001");
("MC","Little Apple");
(map);
}
Another method is also very commonly used: use the feature of struts2 to define a List<Object> variable in Action (taking this example as an example, named: sjxList), and set the set and get methods.
Add content through a HashMap object, such as:
</pre>When returning to the interface, "Little Apple" will be displayed in the select drop-down box of the interface.
<pre name="code" class="html">The easiest way: Directly injspAdd the page manuallyselectTagsOPTIONitem <html> <body> <form> <select name="cars"> <option value="volvo">Volvo</option> <option value="binli">Binli</option> <option value="mazda" selected="selected">Mazda</option> <option value="audi">Audi</option> </select> </form> </body> </html>