Select option Summary

Source: Internet
Author: User
Tags bind

<!--======= A piece of code that determines which select option is selected ================-->

&lt;form name= "Form1" &gt;


&lt;select name= "File_source" size= "1" id= "File_source"


onchange= "alert" (document.form1.file_source.options[


document.form1.file_source.selectedindex].value) "&gt;


&lt;option value= "selected" Selected&gt; selected &lt;/option&gt;


&lt;option value= "office" &gt; Office &lt;/option&gt;


&lt;option value= "room" &gt; Engine room &lt;/option&gt;


&lt;option value= "Teaching and Teaching Department" &gt; Department &lt;/option&gt;


&lt;option value= "Development room" &gt; Development room &lt;/option&gt;


&lt;/select&gt;


&lt;/form&gt;


&lt;!--=================================================================--&gt;


Application:


//tb2,th1 defines content for CSS


in the
//<select>

&lt;table border= "I" cellpadding= "3" cellspacing= "1" align= "center" class= "TB2"


bordercolor= "#666666" &gt;


&lt;tr&gt;&lt;th colspan= "2" class= "Th1" &gt; Edit page &lt;th&gt;&lt;/tr&gt;


&lt;tr&gt;


&lt;th&gt; Mark &lt;/th&gt;


&lt;td&gt;


&lt;spring:bind path= "obj.map[' FLAG '" "&gt;


&lt;select name= ' &lt;c:out value= ' ${status.expression} '/&gt; ' &gt;


&lt;option value= "0"


&lt;c:if test= "${status.value==0}" &gt;selected&lt;/c:if&gt;&gt; automatic


&lt;/option&gt;


&lt;option value= "1"


&lt;c:if test= "${status.value==1}" &gt;selected&lt;/c:if&gt;&gt; manual


&lt;/option&gt;


&lt;/select&gt;


&lt;/spring:bind&gt;


&lt;/td&gt;


&lt;/tr&gt;


&lt;tr&gt;


&lt;th colspan= "2" &gt;


&lt;input type= "hidden" name= "page number" value= "1"/&gt;


&lt;input type= "Submit" value= "Save"/&gt;


&lt;input type= "button" value= "Back"


onclick= "location.href=" main.do? Page number =1 "&gt;


&lt;/th&gt;


&lt;/tr&gt;


&lt;/table&gt;


&lt;!--


about Select:


name= ' &lt;c:out value= ' ${status.expression} '/&gt; '


value= "0"


Name=value


value corresponds to name: 0 is the value of ${status.expression}


in the actual operation, select a Drop-down menu, which means that the page range to


name assigns the selected value. about using link transfer values: main.do? page number = 1


In the entire page: name= "page number" corresponds to value= "1".


them to other pages as a form of argument (other pages also have name= "page number" value= "?" )


--&gt; &lt;!--=================================================================--&gt;


&lt;!--


Prerequisite:

The
display Select, that is, size= "1" (mostly used in this form, more realistically) ①select.options ("id") method to remove an option ② that the index of option cannot change its index value through Option.index ③ the SwapNode method of option to exchange the index ④ Select an option through the Selectindex of the Select


--&gt;


"Full Code"


&lt;head&gt;


&lt;script&gt;


&lt;!--


function Start ()


{//Let "Hong" as the first item first show, see how I get the option


//This demand should be a lot, but I haven't found it on the Internet


//Note: There are multiple IDs for Hong, which will return an option set


//id/name can not be Chinese characters, just tuned for half a day to find out the reason for the


var source=document.form1.seltest.options ("the");


alert ("Put" "+source.innerhtml+" "to the Top"); Swap position


Source.swapnode (document.form1.selTest.options (0));


//With [] can also, Why?


Source.swapnode (document.form1.seltest.options[0]);


//day, also thought that no exchange of success, the original is the selected item did not change, we let it selected


document.form1.seltest.selectedindex=0;


//Note: This method is mainly to give a string, the same as the string to the first few positions.


//Just thought you could get the item this way:


//document.getelementbyid ("InnerHTML").


}


function AX ()


{


//Get div for display


var Show=document.getelementbyid ("show");


var Tempindex=document.form1.seltest.selectedindex;


show.innerhtml= "Index of selected items:" +document.form1.seltest.selectedindex+ "&lt;br&gt;";


show.innerhtml+= "The value of the item just selected: (direct fetch, simplest)" +document.form1.seltest.value+ "&lt;br&gt;";


show.innerhtml+= "The value of the item just selected:" +document.form1.seltest.options (Tempindex). value+ "&lt;br&gt;";


show.innerhtml+= "Just checked the display of the item (via index, very troublesome):" +document.form1.seltest.options (Tempindex). InnerHTML;


show.innerhtml+= "Just select the display portion of the item (via index, followed by text, Why?):" +document.form1.seltest.options (Tempindex). text;


}


--&gt;


&lt;/script&gt;


&lt;/head&gt;


&lt;BODY&gt;


&lt;form name= "Form1" &gt;


&lt;div id= "Show" &gt;&lt;/div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;


&lt;select name= "Seltest"


onchange= "Javascript:ax ();" &gt;


&lt;option value= "AX0" &gt; Zhang &lt;/option&gt;


&lt;option id= "Hong" value= "AX1" &gt; Flood &lt;/option&gt;


&lt;option value= "AX2" &gt; Zhi &lt;/option&gt;


&lt;/SELECT&gt;


&lt;input value= "Change option Order" type= "button" onclick= "Javascript:start ();" &gt;


&lt;/FORM&gt;


&lt;/BODY&gt;
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.