Freemarker write select component (4)

Source: Internet
Author: User

Freemarker write select component


1. macro definition

<# Macro select ID datas value = "" Key = "" text = "" headkey = "" headvalue = ""> <select id = "$ {ID}" name =" $ {ID} "> <option> --- Select --- </option> <# If headkey! = ""> <Option value = "$ {headkey}" >$ {headvalue} </option> </# If> <# list datas as data> <# If key! = ""> <# If value = data [Key]? String> <option value = "$ {data [Key]}" selected >$ {data [text]} </option> <# else> <option value = "$ {data [Key]} ">$ {data [text]} </option> </# If> <# else> <# If value = data> <option value =" $ {data} "selected >$ {data} </option> <# else> <option value =" $ {data} ">$ {data} </option> </# if> </# list> </SELECT> </# macro>

2. Introduce macros

<@ Items. Select id = "username" datas = Users Key = "userno" text = "username" headkey = "0" headvalue = "other"/>

3. Sample Results

<Select id = "username" name = "username"> <option> --- Select --- </option> <option value = "0"> others </option> <option value = "1"> Zhang Sanfeng </option> <option value = "2"> Li Sisi </option> <option value = "3"> Zhao Wu </option> <option value = "4"> Liu Xue </option> <option value = "5"> Zhu Gu </option> <option value = "6"> Zhao Wu </option> <option value = "7"> Wu Yu </option> <option value = "8"> Xue Yu </option> </SELECT>


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.