| <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"> <Html> <Head> <Base href = "<% = basePath %>"> <Title> My JSP 'index. jsp 'starting page </title> <Meta http-equiv = "pragma" content = "no-cache"> <Meta http-equiv = "cache-control" content = "no-cache"> <Meta http-equiv = "expires" content = "0"> <Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3"> <Meta http-equiv = "description" content = "This is my page"> <! -- <Link rel = "stylesheet" type = "text/css" href = "styles.css"> --> <Script type = "text/javascript" src = "jquery-1.4.js"> </script> <Script type = "text/javascript"> $ (Document). ready (function (){ // Button $ ("# But"). click (function (){ Alert ("This is my JSP page "); }); // Text box $ ("# Btext"). click (function (){ Alert ($ ("# te"). val ()); }); // Drop-down list $ ("# Sel"). change (function (){ Alert ($ ("# sel"). val ()); }); // Single region $ ("# Uradio1"). click (function (){ Alert ($ ('input [name = "radiobuttid = on"]: checked'). val ()); }); $ ("# Uradio2"). click (function (){ Alert ($ ('input [name = "radiobutton"]: checked'). val ()); }); $ ("# Uradio3"). click (function (){ Alert ($ ('input [name = "radiobutton"]: checked'). val ()); }); // Check box $ ("# Ucheck"). click (function (){ Var str = ""; // defines an array $ ('Input [name = "checkbox"]: checked'). each (function () {// traverse each check box named interest, where the selected execution function Str + = $ (this). val (); // Add the selected value to the array chk_value }); Alert (str ); }); // Select all $ ("# Checkall"). click (function (){ $ ("Input [name = 'items ']"). attr ("checked", true ); }); // None $ ("# CheckallNo"). click (function (){ $ ("Input [name = 'items ']"). attr ("checked", false ); }); // Invert Selection $ ("# Check_revsern"). click (function (){ $ ("Input [name = 'items ']"). each (function (){ $ (This). attr ("checked ",! $ (This). attr ("checked ")); }); }); // Select all/reselect $ ("# CheckItems"). click (function (){ $ ("Input [name = 'items ']"). attr ("checked", $ (this). get (0). checked ); }); // Form Verification $ ("# Nameid"). hide (); $ ("# Ageid"). hide (); $ ("# Ubu"). click (function (){ If ($ ("# name"). val () = ""){ $ ("# Nameid"). show (); $ ("# Nameid"). fadeOut (3000 ); Return false; } Else if ($ ("# age"). val () = ""){ $ ("# Ageid"). show (); $ ("# Ageid"). fadeOut (3000 ); Return false; } Alert ($ ("# sel"). val ()); Alert ("name:" + $ ("# name"). val () + "" + "age" + $ ("# age"). val ()); }); }); </Script> </Head> <Body> <! -- Button --> <Input type = "button" value = "OK" id = "but"/> <br> <! -- Text box --> <Input type = "text" name = "text" id = "te"/> <input type = "button" id = "btext" value = "value"> <br> <! -- Drop-down box --> <Select id = "sel"> <Option value = "1"> 1 </option> <Option value = "2"> 2 </option> <Option value = "3"> 3 </option> </Select> <Br> <! -- Single region --> <Input type = "radio" name = "radiobutton" id = "uradio1" value = "1"> 1 <Input type = "radio" name = "radiobutton" id = "uradio2" value = "2"> 2 <Input type = "radio" name = "radiobutton" id = "uradio3" value = "3"> 3 <Br> <! -- Check box --> <Input type = "checkbox" name = "checkbox" value = "1"> 1 <Input type = "checkbox" name = "checkbox" value = "2"> 2 <Input type = "checkbox" name = "checkbox" value = "3"> 3 <Input type = "checkbox" name = "checkbox" value = "4"> 4 <Input type = "button" id = "ucheck" value = "OK"> <Br> <! -- Select all and invert check boxes --> <Input type = "checkbox" name = "checkItems" id = "checkItems" value = "select all/select none"/> select all/select none <Br> <Input type = "checkbox" name = "items" value = ""/> football <Input type = "checkbox" name = "items" value = "basketball"/> basketball <Input type = "checkbox" name = "items" value = "swimming"/> swimming <Input type = "checkbox" name = "items" value = "singing"/> singing <Br> <Input type = "button" name = "checkall" id = "checkall" value = "select all"/> <Input type = "button" name = "checkall" id = "checkallNo" value = "NONE"/> <Input type = "button" name = "checkall" id = "check_revsern" value = ""/> <! -- Form verification --> <Form action = ""> Name: <input type = "text" id = "name"> <span id = "nameid" style = "color: # f00;"> name cannot be blank! </Span> <br> Age: <input type = "text" id = "age"/> <span id = "ageid" style = "color: # f00;"> age cannot be blank! </Span> <br> <Input type = "button" id = "ubu" value = "OK"/> </Form> </Body> </Html> |