<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> Untitled document </title> <style type=" Text/css "> <!--. l {font-size:10pt;} --> </style> <script language= "JavaScript" > Function AddThis () {var srce=event.srcelement?event.srcele Ment:event.target; var Thev=srce.value; alert (Thev); var s=document.forms[0].likes.value.indexof (Thev) if (s==-1) {document.forms[0].likes.value+=thev+ ","; } </script> </pead> <body> <form name= "Form1" > <font color= "#666666" > <textar EA name= "likes" cols= "rows=" 2 "id=" textarea9 "></textarea> </font> <table border=" 0 "width=" 10 0% "cellspacing=" 0 "cellpadding=" 0 "> <tr> <td><input name=" Activity "Type= "checkbox" value= "Computer/Network" id= "Activity_1" onclick= "javascript:addthis ()"/> <label for= "Activity_1" Clas s= "L" > Computer/Network </label></td> <td><label for= "activity_2" class= "L" > <input name= "Activity2" type= "checkbox" value= "video game" id= "activity_2" onclick= "javascript:addthis ()"/> Video games </LABEL>&L t;/td> <td><input name= "Activity2" type= "checkbox" value= "Sports" id= "Activity_3" onclick= "Javascript:add" This () "/> <label for=" activity_3 "class=" L "> Sports </label></td> <td><input Name= "Activity2" type= "checkbox" value= "Drinking" id= "Activity_4"/> "<label" for= "Activity_4" class= "L" > alcohol ;/label></td> <td><input name= "Activity2" type= "checkbox" value= "Tea" id= "Activity_5"/> <label for= "Activity_5" class= "L" > Tea </label></td> </tr> <tr> <td> ; <input name= "ActivitY2 "type=" checkbox "Value=" Piano "id=" Activity_6 "/> <label" for= "Activity_6" L "> Piano class= t;/td> <td><input name= "Activity2" type= "checkbox" value= "Watch Movie/TV" id= "Activity_7"/> < Label for= "activity_7" class= "L" > Watch movie/tv </label></td> <td><input name= "Activity2" type= "Chec" Kbox "value=" Chess/Poker "id=" Activity_8 "/> <label for=" activity_8 "class=" L "> Chess/Poker </label></td> ; <td><input name= "Activity2" type= "checkbox" value= "Tourism id=" Activity_9 "/> <label for=" activity _9 "class=" L "> Sightseeing tour </label></td> <td><input name=" Activity2 "type=" checkbox "value=" Shopping "id = "Activity_10"/> <label for= "activity_10" class= "L" > Shopping </label></td> </tr> <tr> <td><input name= "Activity2" type= "checkbox" value= "reading" id= "Activity_11"/> ; Label for= "actIvity_11 "class=" L "> Reading </label></td> <td><input name=" Activity2 "type=" checkbox "value=" writing " Id= "Activity_12"/> <label for= "Activity_12" class= "L" > Writing </label></td> <TD>&L T;input name= "Activity2" type= "checkbox" value= "Cook" id= "activity_13"/> <label "for=" activity_13 "class=" l "> Cooking </label></td> <td><input name=" Activity2 "type=" checkbox "value=" Prom/Karaoke "id=" activity_ "/> <label for=" activity_14 "class=" L "> Prom/Kara ok</label></td> <td><input Name= "Activity2" type= "checkbox" value= "Fitness/Martial Arts" id= "Activity_15"/> <label for= "activity_15" class= "L" > Fitness/Martial Arts </label></td> </tr> <tr> <td><input name= "Activity2" type= checkbox "Value=" Water Activities "id=" Activity_16 "/> <label for=" activity_16 "class=" L "> Water activities </label></td> <td><input Name= "Activity2" type= "checkbox" value= "Theatrical performance" id= "Activity_17"/> "<label" for= "activity_17" class= "L" > Theatrical performances </label></td> <td><input name= "Activity2" type= "checkbox" value= "id=" activity_18 ; <label for= "activity_18" class= "L" > Chat </label></td> <td><input name= "activity2" type= "che Ckbox "value=" id= "activity_19"/> <label for= "activity_19" class= "L" > Family/Handicraft </label></td& Gt <td><input name= "Activity2" type= checkbox "value=" id= "activity_20"/> <label "for=" activity_ "class=" L "> Calligraphy/Painting </label></td> </tr> <tr> <td><input name=" activity 2 "type=" checkbox "value=" "id=" activity_21 "/> <label" for= "activity_21" class= "L" > Savings/Investment </LABEL&G t;</td> <td><input name= "Activity2" type= "checkbox" value= "" id= "activity_22"/>; label for= "activity_22" class= "L" > Pets </label></td> <td><input name= "Activity2" type= "check Box "value=" id= "activity_23"/> <label for= "activity_23" class= "L" > Listening to music </label></td> <td><input name= "Activity2" type= checkbox "value=" "id=" activity_24 "/> <label" for= "Acti" Vity_24 "class=" L > various collection activities </label></td> <td><input name= "activity2" checkbox "Type=" "Id=" activity_25 "/> <label for=" activity_25 "class=" L "> Photography/Art creation </label></td> </ tr> </table> </form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
2006-08-21 can detect themselves, do not add events per checkbox, delete function is not implemented
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "Content=" Tex t/html; charset=gb2312 "/> <title> Untitled document </title> <style type=" Text/css "> <!--. l {font-size:10pt;} --> </style> <script language= "JavaScript" > Function AddThis () {var srce=event.srcelement?event. SrcElement:event.target; if ((srce.tagname== "INPUT") && (srcE.type.toLowerCase () = "checkbox") {var thev=srce.value; var theid=srce.id; alert (Theid); if (Theid.indexof (' Xinge ')!=-1) {thetag= "Xinge"; }else{thetag= "likes"; }//alert (Thetag); Switch (thetag) {case "likes": Var s=document.forms[0].likes.value.indexof (Thev); if (s==-1) {document.forms[0].likes.value+=thev+ ","; } break; Case "Xinge": Var s=document.forms[0].xinge.value.indexof (Thev); if (s==-1) {document.forms[0].xinge.value+=thev+ ","; } break; }} Document.onmousedown=addthis; </script> </pead> <body> <form name= "Form1" ><textarea name= "likes" cols= "$" rows= "8" id = "Textarea9" ></textarea> <textarea name= "Xinge" cols= "" rows= "8" id= "TEXTAREA9" ></textarea> <table border= "0" width= "100%" cellspacing= "0" cellpadding= "0" > <tr> <td colspan= "5" > Hobbies & lt;/td> </tr> <tr> <td><input name= "activity" type= checkbox "value=" Computer/network "id=" Activity_1 "/> <label for=" activity_1 "class=" L "> Computer/Network </label></td> <TD>< ; label for= "Activity_2" class= "L" > <input name= "activity2" type= "checkbox" value= "video game" id= "Activity_2"/&G T Video games </label></td> <td><input name= "Activity2" type= "checkbox" value= "Sports" id= "Activity_3"/& Gt <label for= "Activity_3" class= "L" >Sports </label></td> <td><input name= "Activity2" type= "checkbox" value= "Drinking" id= "Activity_4"/> ; <label for= "Activity_4" class= "L" > Alcohol </label></td> <td><input name= "activity2" type= "che Ckbox "value=" tea "id=" activity_5 "/> <label for=" activity_5 "class=" L "> Tea </label></td> </tr> <tr> <td><input name= "Activity2" type= "checkbox" Value= "Piano" id= "Activity_6"/ > <label for= "activity_6" class= "L" > Piano </label></td> <td><input name= "act Ivity2 "type=" checkbox "value=" Watch Movie/TV "id=" activity_7 "/> <label for=" activity_7 "class=" L "> Watch movie/TV ;/label></td> <td><input name= "Activity2" type= "checkbox" value= "Chess/Poker" id= "Activity_8"/> <label for= "Activity_8" class= "L" > Chess/Poker </label></td> <td><input name= "Activit" Y2 "type="CheckBox "value= Tourism" id= "Activity_9"/> <label for= "Activity_9" class= "L" > Sightseeing tourism </label></td > <td><input name= "activity2" type= "checkbox" value= "shopping" id= "activity_10"/> <labe L for= "activity_10" class= "L" > Shopping </label></td> </tr> <tr> <td><in Put name= "Activity2" type= "checkbox" value= "read" id= "Activity_11"/> "<label" for= "Activity_11" class= "L" &G t; reading </label></td> <td><input name= "Activity2" type= "checkbox" value= "writing" id= "Activity_12"/&G T <label for= "Activity_12" class= "L" > Writing </label></td> <td><input name= "activity2" type= "ch Eckbox "value=" Cooking "id=" activity_13 "/> <label for=" activity_13 "class=" L "> Cooking </label></td> <td><input name= "Activity2" type= "checkbox" value= "Prom/Karaoke" id= "activity_14"/> <label For= "ActIvity_14 "class=" L "> Prom/Kara ok</label></td> <td><input name=" Activity2 "type=" checkbox "value = "Fitness/Martial Arts" id= "Activity_15"/> <label for= "activity_15" class= "L" > Fitness/Martial Arts </label></td> </tr> <tr> <td colspan= "5" > Character:</td> </tr> <tr> <TD&G T;<input name= "Activity2" type= "checkbox" value= "lively" id= "xinge_16"/> <label "for=" Xinge_16 "L" > Lively </label></td> <td><input name= "Activity2" type= "checkbox" value= "Sharp" id= "xinge_17"/> ; <label for= "xinge_17" class= "L" > "Vitriol </label></td> <td><input name=" Activity2 "type=" check Box "value=" id= "xinge_18"/> <label for= "xinge_18" class= "L" > Self-closing </label></td> <td><input name= "Activity2" type= checkbox "value=" and so on "id=" xinge_19 "/> <label for=" xinge_19 "C Lass= "L" ≫ et cetera </label></td> <td><input name= "Activity2" type= "checkbox" value= "Extrovert" id= "xinge_20"/> <label for= "xinge_20" class= "L" > Outward </label></td> </tr> </table> < /form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Blueidea owner reply, recommend
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> Untitled document </title> <style type=" Text/css "> <!--. L {font-size:10p t;} --> </style> <script language= "JavaScript" > var likes=new Array (); Xinge=new Array (); function AddThis (e) {var e, Srce, op, opt, I; E=window.event?window.event:e; Srce=e.srcelement?e.srcelement:e.target; if (!srce) return; if (String (srce.tagname). toLowerCase ()!= "Input" | | String (Srce.type). toLowerCase ()!= "checkbox") return; if (SrcE.id.indexOf ("Xinge")!=-1) {op=xinge; Opt=document.forms[0].xinge}else{op=likes; opt=document.forms[0]. Likes; } if (srce.checked) {i=-1; while (Op[++i]) if (op[i]==srce.value) return; Op[i]=srce.value; }else{I=-1; WHile (Op[++i]) if (op[i]==srce.value) {op.splice (i,1); i--;} } Opt.value=op; } document.onkeydown=document.onchange=document.onclick=addthis; </script> </pead> <body> <form name= "Form1" ><textarea name= "likes" cols= "8" Id= "Textarea9" ></textarea> <textarea name= "Xinge" cols= "" rows= "8" id= "TEXTAREA9" ></textarea> ; <table border= "0" width= "100%" cellspacing= "0" cellpadding= "0" > <tr> <td colspan= "5" > Interest in Love Good </td> </tr> <tr> <td><input name= "activity" type= "checkbox" value= "Computer/Network" Id= "Activity_1"/> <label for= "activity_1" class= "L" > Computer/Network </label></td> <TD ><label for= "activity_2" class= "L" > <input name= "activity2" type= "checkbox" value= "video game" id= "Activi Ty_2 "/> Video games </label></td> <td><input name=" Activity2 "type=" checkbox "VAlue= "Sports" id= "Activity_3"/> <label for= "activity_3" class= "L" > Sports </label></td> <td><input name= "Activity2" type= "checkbox" value= "Drinking" id= "activity_4/>" <label Vity_4 "class=" L "> Alcohol </label></td> <td><input name=" Activity2 "type=" checkbox "value=" Tea " Id= "Activity_5"/> <label for= "activity_5" class= "L" > Tea </label></td> </tr> <tr> <td><input name= "Activity2" type= "checkbox" Value= "Piano" id= "Activity_6"/> <label for= "Activity_6" class= "L" > Piano </label></td> <td><input name= "Activity2" type = "checkbox" value= "Watch Movie/TV" id= "activity_7"/> <label for= "activity_7" class= "L" > Watch movie/TV </label> </td> <td><input name= "Activity2" type= "checkbox" value= "Chess/Poker" id= "Activity_8"/> <label for= "Activity_8 "class=" L "> Chess/Poker </label></td> <td><input name=" Activity2 "type=" checkbox "value=" Sightseeing Tour " Id= "Activity_9"/> <label for= "Activity_9" class= "L" > Sightseeing tour </label></td> <td& Gt;<input name= "Activity2" type= "checkbox" value= "shopping" id= "activity_10"/> <label "for= activity_10" class= "L" > Shopping </label></td> </tr> <tr> <td><input name= "Activi Ty2 "type=" checkbox "value=" read "id=" Activity_11 "/>" <label "for=" Activity_11 "class=" L "> Reading </label& gt;</td> <td><input name= "Activity2" type= "checkbox" value= "writing" id= "Activity_12"/> <label for= "Activity_12" class= "L" > Writing </label></td> <td><input name= "Activity2" type= "checkbox" value= "Cooking" id= "activity_13"/> <label for= "activity_13" class= "L" > Cooking </label></td > <td><input name= "Activity2" type= "checkbox" value= "Prom/Karaoke" id= "activity_14"/> <label for= "Activity_14" class= "L" > Prom/Kara ok</label></td> <td><input name= "Activity2" type= "checkbox" value= "Fitness/Martial Arts" Id= "Activity_15"/> <label for= "activity_15" class= "L" > Fitness/Martial Arts </label></td> </t r> <tr> <td colspan= "5" > Character:</td> </tr> <tr> <td> <input name= "Activity2" type= "checkbox" value= "lively" id= "xinge_16"/> <label "for=" Xinge_16 "L" > Lively </label></td> <td><input name= "Activity2" type= "checkbox" value= "Sharp" id= "xinge_17"/&G T <label for= "xinge_17" class= "L" > Vitriol </label></td> <td><input name= "Activity2" type= "Chec" Kbox "value=" id= "xinge_18"/> <label for= "xinge_18" class= "L" > Autistic </label></td> <tD><input name= "Activity2" type= checkbox "value=" and so on "id=" xinge_19 "/> <label for=" xinge_19 "class = "L" > et </label></td> <td><input name= "activity2" type= checkbox "value=" Outward "id=" xinge_20 "/> <label for=" xinge_20 "class=" L "> extroversion </label></td> </tr> </table& Gt </form> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Splice method
Removes one or more elements from an array and, if necessary, inserts a new element at the position of the removed element, returning the removed element.
Arrayobj.splice (Start, DeleteCount, [item1[, item2[, ...) [, Itemn]]]
Parameters
Arrayobj required option. An Array object.
Start
Required option. Specifies that the starting position of the element is removed from the array, which is calculated starting at 0.
DeleteCount
Required option. The number of elements to remove.
Item1, item2,.. ., itemn
Required option. The new element to insert at the location of the removed element.
Description
The splice method modifies arrayobj by removing the specified number of elements starting from the start position and inserting new elements. The return value is a new Array object that consists of the removed element.