<pre name= "code" class= "Java" >
Drop-down box label in JSP:
<s:select name= "SJX" id= "SJX" list= "sjxlist" "BM" listkey= "MC" listvalue= "size=" cssstyle= : 70px; border:0 "multiple=" true ></s:select>
Copy Code code as follows:
<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 ">
In JS, the way to create items under the Select tab is flexible:
Copy Code code as follows:
<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 with Ext.getdom (' SJX ')
var ooption = document.createelement ("option"); <span style= "White-space:pre" > </span>// The option sub tag in JS to create the Select label
OSelect.options.add (ooption); <span style= "White-space:pre" > </span>//Add the new Option Child label to the Select label
Ooption.value = "001"; <span style= "White-space:pre" > </span>//content corresponding value value
ooption.innerhtml = "Small Apple"; <span style= the contents of the Drop-down box displayed by the "White-space:pre" > </span>//
... Analogy
This approach in NOTE:JS is useful in specific situations, such as: This request does not return a specific interface, that is, not refreshing the entire interface. Instead of using an AJAX-style asynchronous request to do some local data requests, then the following Strut2 method will be ineffective.
Copy Code code as follows:
<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 is also very common: using the Struts2 feature, define a list<object> variable in the action (in this case, named: sjxlist) and set the set, get method.
Add content through a HashMap object, such as:
When the </pre> returns to the interface, the "Little Apple" is displayed in the Select Drop-down box of the interface.
<pre name= "code" class= "HTML" > one of the easiest ways to manually add a select label to a JSP page