Page 143 - DCAP202_Fundamentals of Web Programming
P. 143

Fundamentals of Web Programming




                    Notes          3.  The ..................................... event is often used to check the visitor’s browser type and browser
                                       version, and load the proper version of the web page based on the information.
                                   4.  The  onFocus,  onBlur  and  onChange  events  are  often  used  in  combination  with
                                       ................................. of form fields.
                                   5.  The ................................. event is used to validate ALL form fields before submitting it.
                                   6.  onMouseOver and onMouseOut are often used to create “............................” buttons.

                                   11.2 onClick Event Handler and onSelect Event Handler


                                   In this section, we will discuss onClick Event Handler and onSelect Event Handler.

                                   11.2.1 onClick Event Handler

                                   The onclick property returns the onClick event handler code on the current element.




                                     Notes  When using the onclick event to trigger an action, also consider adding this same
                                     action to the onkeydown event, to allow the use of that same action by people who don’t
                                     use a mouse or a touch screen.

                                   Syntax
                                   element.onclick  =  functionRef;
                                   where functionRef is a function - often a name of a function declared elsewhere or a  function
                                   expression.



                                     Did u know?   The  event  object  passed  to  the  specified  event  handler  function  is  a
                                     MouseEvent.

                                   11.2.2 onSelect Event Handler

                                   A select event occurs when a user selects some of the text within a text or textarea field.


                                       !
                                     Caution  The onSelect event handler executes JavaScript code when a select event occurs.


                                          Example: The following example uses an onSelect handler in the valueField text object to
                                   call the selectState() function.
                                   <INPUT  TYPE=”text”  VALUE=””  NAME=”valueField”  onSelect=”selectState()”>

                                   Self Assessment

                                   Fill in the blanks:
                                   7.  The ............................ property returns the onClick event handler code on the current element.

                                   8.  ............................ is often a name of a function declared elsewhere or a function expression.




          136                               LOVELY PROFESSIONAL UNIVERSITY
   138   139   140   141   142   143   144   145   146   147   148