TAILIEUCHUNG - Ajax in Action phần 7

Nếu người dùng đang gõ một từ, một trong hai chức năng này sẽ bắt đầu một tìm kiếm mới, kiểm tra các máy chủ cho dữ liệu phù hợp, hoặc nó sẽ làm việc với tập hợp kết quả lưu trữ. Nếu chúng ta không cần để có được dữ liệu mới từ máy chủ | The client-side framework 379 If the user is typing a word either this function will start a new search checking the server for matching data or it will work with the cached result set. If we do not need to get new data from the server then we can call a BuildList function which will limit the result set. We explain more about that in the section Building the results span later in this chapter. The GiveOptions function is declared with the parameter e which allows us to detect the source of the event. The first thing we need to declare is a local variable intKey. This variable holds the code of the key that the user pressed o. To determine which key was pressed we must determine what method the user s browser needs to function. If the property is supported then we know the browser is IE. We use to obtain the key code value and we also use to get the object of the user s textbox. For the other browsers we use to obtain the key code value and to obtain the textbox object reference. We then need to check whether the textbox is using a timer to hide the textbox 0. To do so we reference the textbox s obj property which we created earlier and the boolean useTimeout. If the timer is running we cancel it and then restart it by calling the functions EraseTimeout and StartTimeout which we will code in the section Using JavaScript timers. We then check to see if anything is in the textbox Q. If nothing is there we call a HideTheBox function which is developed in the section Setting the selected value set the strLastValue to null and return false to exit the function. If the textbox contains text then we can continue. Before we can detect the Enter key and arrow keys we need to verify that the current active textbox is the same textbox as the last textbox that was active. The first key to detect is the Enter key which has a key code of 13 0. The Enter key will allow us to grab the value of the selected drop-down item

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