The HTML page returned after the form is submitted is re-rendered. The value and selectedIndex attributes of the SELECT control cannot keep the drop-down box in the status before the form is submitted. Next, we will share with you how to change the options of the HTML drop-down box, if you are interested, you can study the HTML page returned after the form is submitted for re-rendering. The value and selectedIndex attributes of the SELECT control cannot make the drop-down box retain the status before the form is submitted.
The Code is as follows:
All Pass Last pass Pending
A temporary solution is to add a script at the end of the vm file to assign a value to the drop-down box.:
The Code is as follows:
Script
$ ('# Idstate'). val (' $! {State }');
Script
Another solution is to set the selected items by default.:
The Code is as follows:
All Pass Last pass Pending
In VTL format:
The Code is as follows:
All Pass Last pass Pending
Note that when performing = comparison, Velocity is of different type. If you use strings "1", "2", and "3", the system always returns false.
Comparison in velocity
For velocity, comparison is particularly difficult to implement when unequal comparisons (greater than or less than) are involved. Now I want to display the file size categories (Bytes, MB, and GB) on the page, so it involves the problem of comparing the filesize. Is there any better way to achieve this?
For example, the following code:
The Code is as follows:
# If ($ filesize> 1024 & $ filesize <1048567)
# Set ($ ksize = $ filesize % 1024)
File Size: $ ksize KB
# Elseif ($ filesize> 1048567 & amp; $ filesize <1073731824)
# Set ($ msize = $ filesize % 1048567)
File Size: $ msize MB
# Elseif ($ filesize> 1073731824)
# ($ Gsize = $ filesize %1073731824)
File Size: $ gsize GB
# Else
File Size: $ filesize Bytes
# End
The Code is as follows: