Web Programming with HTML, XHTML, and CSS Second Edition- P11

Web Programming with HTML, XHTML, and CSS Second Edition- P11: Điều này bắt đầu hướng dẫn nhận xét HTML và cũng giới thiệu đến bạn bằng cách sử dụng XHTML cho cấu trúc của một trang web và cascading style sheets (CSS) để kiểm soát như thế nào một tài liệu sẽ xuất hiện trên một trang web. Bạn se tìm hiểu làm thế nào để tận dụng lợi thế của các tính năng mới của các trình duyệt trong khi đảm bảo rằng các trang của bạn vẫn làm việc ở cũ, nhưng phổ biến, các trình duyệt. Bằng. | Chapter 12 Working with JavaScript To give focus to the first text input on a form simply add an onload event handler to the body element of the document. This handler selects the form control that you want to highlight and uses the focus method of that control to give it focus as follows body onload When the page loads the cursor should be flashing in the form control that you have selected ready for the user to enter some text See Figure 12-10. Note that the onload event fires when the complete page has loaded not as soon as it is come across in the order of the page . Figure 12-10 Auto-Tabbing Between Fields The focus method can also be used to pass the focus of one control to another control. For example if one of the controls on a form is to provide a date of birth in MM DD YYYY format then you can move focus between the three boxes as soon as the user enters a month and then again once the user has entered a day form name frmDOB Enter your date of birth br input name txtMonth id txtMonth size 3 maxlength 2 onkeyup if 2 input name txtDay id txtDay size 3 maxlength 2 onkeyup if 2 input name txtYear id txtYear size 5 maxlength 4 onkeyup if 4 input type submit name submit value Send form This example uses the onkeyup event handler to check that the length of the text the user has entered is equal to or greater than the required number of characters for that field. If the user has entered the required number of characters the focus is moved to the next box. Note how the length of the text input is discovered using . The this keyword indicates the current form control whereas the value property indicates the value entered for the control. 471 Chapter 12 Working with JavaScript Then the length property returns the length of the value entered for the control. This is

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.