Multiple methods for changing the SELECT option in the HTML drop-down box _ HTML/Xhtml _ webpage Creation

Source: Internet
Author: User
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:


 

 

 

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.