Home  >  Article  >  Web Front-end  >  Various methods to change the SELECT option of HTML drop-down box_HTML/Xhtml_Web page production

Various methods to change the SELECT option of HTML drop-down box_HTML/Xhtml_Web page production

WBOY
WBOYOriginal
2016-05-16 16:40:401924browse

The HTML page returned after submitting the form is re-rendered. Neither the value nor selectedIndex attributes of the SELECT control can make the drop-down box retain the state before submitting the form.

Copy code
The code is as follows:



A temporary solution is to add a script at the end of the vm file to assign a value to the drop-down box :

Copy code
The code is as follows:

<script> <br>$('#idState').val( '$!{state}'); <br></script>

Another solution is to set the default selected item :

Copy code
The code is as follows:



The way to write it in VTL is :

Copy the code
code As follows: