For the dropdown box is a very large operation, these days the project needs to summarize
First, dynamic construction option
Sometimes we need to dynamically build the values in the dropdown box, where we'll use var varitem = new Option ("text", "value"), build one or more <option value= "value" > Text </option>
var varitem = new Option ("Studentname", "name");
Example 1: When the form is loaded, an option is automatically constructed
Of course, I think it should be possible to build multiple options at once, may be declaring an array or a JSON object to add, but specifically how to add more than one option at a glance, will friends look pointingExample 2: The use of JS to delete a column for the Stunumber drop-down selection box, later if made dynamic, you can use the call method to delete the specified column of information.
Example 3: Delete the value of the selected drop-down box, can be implemented by an event method, we can randomly select a column, and then click the button, then the column will be deleted
Example 4: Empty the value in the drop-down selection box
Example 5: To get the value of option inside name, we pass a button event, click, Pop Up the dialog box, the information inside is the value of name
Example 6: Output the subscript value of option, starting from 0
Second, the echo of select (combined with JSP)
Usually when we do update user information, we need to echo the drop-down selection box information, this time if you use JSP development, you can use the JSTL tag <c:if>
First introduce the JSTL tag library: <%@ taglib prefix= "C" uri= "Http://java.sun.com/jsp/jstl/core"%>
<select id= "Sort" value= "${sort}" ><option name= "name" <c:if test= "${' name ' eq sort}" >selected</c:if >>studentname</option><option name= "Stunum" <c:if test= "${' stunum ' eq sort}" >selected</c:if >>studentnumber</option></select>
Continuous summary in ~ ~ ~
Reference blog:
Http://www.cnblogs.com/Herist/archive/2007/09/24/903890.htmlhttp://www.jb51.net/article/44657.htm
(Reproduced this site article please indicate the author and sourceCoderthe extraordinary, do not use for any commercial use)
JavaScript Learning Notes drop-down selection box action