JavaScript in 10 Simple Steps or Less 2007 phần 4

Về cơ bản, các thông số này giống như các biến: tên là container cho các giá trị. Trong JavaScript, đối tượng tài liệu cung cấp tài sản URL có chứa các URL cho toàn bộ tài liệu của bạn, và sử dụng một số thao tác trên thuộc tính này, bạn có thể trích xuất một số hoặc tất cả các tham số URL có trong URL. | Working with Forms 171 order to display the text in a dialog box. The final page looks like Listing 82-1. Task body form name myForm select name mySelect option value First Choice 1 option option value Second Choice 2 option option value Third Choice 3 option select form a href onClick document. Check Selection List a body Listing 82-1 Accessing the value of a selected option in a selection list. 6. Save the file and close it. 7. Open the file in your browser. You should see the form and link as in Figure 82-1. Figure 82-1 A form with a selection list. 8. Select an option from the selection list and then click the link to see the value of that selection displayed in a dialog box. cross-references Task 83 shows you how to programmatically populate a selection list. Task 85 shows you how to detect when a selection is made in a selection list. 172 Part 4 Task 3 Programmatically Populating a Selection List notes A key point here The length property contains the number of elements in the list. For instance if there are three elements then the value is 3. But the options array like all arrays starts counting at zero. So the index of that last third element is 2. You need to keep this in mind when working with selection lists dynamically from JavaScript. The use of the short-form operator increases the operand before it by one. For instance a is the same as a a 1. A text property is used to hold the text that will be displayed on the form. The value property is used to hold the value of the entry. You can dynamically add entries to a selection list through JavaScript without ever using an option tag in HTML to create the selection entry. The principle is simple. The selection list object has a length property indicating the number of entries in the selection list. Increasing this value by 1 creates an empty entry at the end of the list as illustrated in Figure 83-1. Figure 83-1 Adding a new entry to a selection list. Once the new entry .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
92    192    3    30-04-2024
Đã 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.