TAILIEUCHUNG - JavaScript Bible, Gold Edition part 76

JavaScript Bible, Gold Edition part 76. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 598 Part III Document Objects Reference Listing 26-2 continued var lang 0 .geekLevel 0 .checked plain hard empty options from list while O create new option object for each entry for var i 0 i i newOpt lang plain plainList i hardList i newOpt 0 .selected true Modifying SELECT options W3C DOM Yet another approach is possible in browsers that closely adhere to the W3C DOM Level 2 standard. In NN6 for example you can use the add and remove methods of the SELECT element object. They work very much like the same-named methods for the options array in IE4 but these are methods of the SELECT element object itself. The other main difference between the two syntaxes is that the NN6 add method does not use the index value as the second parameter but rather a reference to the OPTION element object before which the new option is inserted. The second parameter is required so to simply append the new item at the end of the current list supply null as the parameter. Listing 26-3 shows the W3C-compatible version of the SELECT element modification scripts shown in Listings 26-1 and 26-2. I highlight source code lines in bold that exhibit differences between the IE4 and W3C DOM versions. Listing 26-3 Modifying SELECT Options NN6 change color language set function setLang which var listObj 0 .colors var newOpt filter out old IE browsers if find out if it s 3 or 6 entries var listLength save selected index var currSelected replace individual existing entries for var i 0 i listLength i newOpt which plain plainList i hardList i SELECT Chapter 26 Select Option and FileUpload Objects 599 i newOpt i currSelected create entirely new options list function setCount choice .

TỪ KHÓA LIÊN QUAN
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.