TAILIEUCHUNG - Professional Information Technology-Programming Book part 75

Tham khảo tài liệu 'professional information technology-programming book part 75', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Creating Form Elements Now let s look at how some of the items in an HTML form can be generated by using custom PHP functions. This type of modularization means that you can use a function over and over again whenever you need to include the same type of item on a form. Creating a Dynamic Radio Button Group A modular routine to generate a radio button group requires three pieces of information the name of the group a list of values and a list of labels. You can use an associative array to pass the values and labels to the function in one go. Say you want to be able to generate the HTML for a radio button group by using simple code similar to the following options array economy Economy standard Standard express Express default economy html generate_radio_group shipping options default As you can see this is the kind of function you are likely to use again and again when creating HTML forms and it is very useful to build up a toolbox of similar functions to make it easy to perform common tasks. Here s how the generate_radio_group function might be implemented function generate_radio_group name options default name htmlentities name foreach options as value label value htmlentities value html . INPUT TYPE RADIO if value default html . CHECKED html . NAME name VALUE value html . label . br return html At the heart of the function is a loop through options that generates each INPUT tag in turn giving each tag the same NAME attribute but a different VALUE attribute. The label text is placed next to each button and in this sample function the only formatting is to place a br tag between each button in the group. You could format the options in a table or in any other way you see fit. At each step of the loop the script compares the current value of value with the passed-in default value. If they match the CHECKED attribute is included in the generated HTML. Again spacing is important here note that the space after CHECKED is added to the HTML string. The default argument

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.