This article is mainly on the use of JS form in a detailed summary of the introduction, the need for friends can come to the reference, I hope to help you.
1.javascript Refresh Page method window.location.reload (); Use window.open () pop-up pop-up window, refresh parent window Window.opener.location.reload () Use Window.showdialog pop-up mode window & nbsp Window.dialogArguments.location.reload (); 2.javascript pop-up window two implementations---below give two pop-up screen center window example window.open () mode code as follows: function showdialog (URL) { &NBSP ; var iwidth=300; Window width var iheight=200;//window height var itop= ( Window.screen.height-iheight)/2; var ileft= (window.screen.width-iwidth)/2; window.open (URL, "Detail", "scrollbars=no,toolbar=no,location=no,direction= No,resizeable=no, width= "+iwidth+", height= "+iheight+", top= "+itop+", left= "+ileft"; } window.showModalDialog mode &NBSP; code as follows: function showdialog (URL) { var iwidth=300;//Windows Mouth width var iheight=200;//window height var itop= (win Dow.screen.height-iheight)/2; var ileft= (window.screen.width-iwidth)/2; window.showmodaldialog (Url,window, "dialogheight:" +iheight+ px; dialogwidth: "+iwidth+" PX; dialogtop: "+itop+"; Dialogleft: "+ileft+"; Resizable:no; Status:no;scroll:no "); } Note the second parameter here is,window 3. To set a method for not caching data in a page Add the following statement to the JSP page code as follows: <% Response.setheader ("Pragma", "No-cache"); Response.setheader ("Cache-control", "No-cache"); Response.setdateheader ("Expires", 0); %> 4. The method code to close the page without prompting is as follows: function Closewin () {&nbsP var ua = navigator.useragent; var ie = navigator.appname== "Microsoft Internet Explorer"?true:false; if (ie) { var ieversion = PA Rsefloat (Ua.substring (Ua.indexof ("MSIE") +5,ua.indexof (";", Ua.indexof ("MSIE"))); if (ieversion < 5.5) { var str = '; Document.body.insertAdjacentHTML ("BeforeEnd", str); &NB Sp;document.all.notipclose.click (); } else { Window.opener =null; Window.close () ;   }else{ window.close () }} 5, Timed shutdown pop-up window---set/clear timer &NBSP The code is as follows: Scriptlanguage= "JavaScript" !-- Functioncloseit () { settimeout ("Self.close ()", 100000)// Unit is milliseconds, here is 100 sec SetInterval ("Self.close ()", 100000) Window.cleartimeout (Me.timer); Window.clearinterval (Me.timer); /script 6.javascript pop-up window in the Pass value---Pass the value through the URL code is as follows: < Script language= "javascript"Type=" Text/javascript > Function fn_modify (PID) { var modifyinfo=new Object (); window.showModalDialog ("modify_main.asp?pid=" +pid,modifyinfo, "Dialogheight:180px;dialogwidth:300px;dialogleft: ;d Ialogtop:;resizable:off;center:on;help:off;scroll:off;status:off ") reload (); function Reload () {location.href= "abc.asp";} </SCRIPT> <a href= "abc.asp" onclick= "fn_modify" (' This is the value ') ' > click </a> 7.js hide/Show form document.all ("id"). style.display== "None";//Hide document.all (" ID "). style.display==" ";//Show document.getElementById (" BT "). style.display==" None "document.getElementById (" BT "). style.display== ID 8.js Controls the valid/invalid document.getElementById ("BT") of the form element. Disabled=true; document.all ("Submit1"). disabled=true;//invalid document.all ("Submit1"). disabled=false;//valid set/Get the value of an element document.getElementById ("Labtitle"). Innerhtml= "IP mode";//Set Value document.getElementById ("Labtitle"). innerhtml//Get Value Labtitle for div,span,table ID Example 1: &The code is as follows: <input id= "MyText" type= "text" value= "I am not available" > <input type= "button" value= "Disabled" onclick= " Javascript:document.all.mytext.disabled= ' false ' > <input type= button ' value= ' Enable ' onclick= ' javascript: Document.all.mytext.removeAttribute (' disabled ') > Example 2: Code is as follows: <input id= "MyText" type= "text" Value= "I am able to use" > <input type= "button" value= "Disable" onclick= "if (mytext.disabled==false) {mytext.disabled=true Mytext.value = ' I am not able to use '; This.value= ' Enable '} else {mytext.disabled=false;mytext.value= ' I am able to use '; This.value= ' Disable '} ' > 9. How the page submits the form by function code as follows: function exit () {selcardform.action= "/ndhotel/ Querytroom.do?method=exitsystem "; Selcardform.submit (); } 10. Traversal Radio method code is as follows: <input id= "Mode1" type= "Radio" name= "Workmode" value= "1" checked> &N Bsp var radios=document.getelementsbyname ("Workmode"); var workmode= ""; for (var i=0;i<radios.length;i++) { &nbsP if (radios[i].checked==true) { Workmode=radios[i].value; & nbsp   &NBSP} 11. Add the option code to the select as follows: <select id= "Ddlprovi nCE "Name=" ddlprovince "onchange=" Cityresult () "> var prov=document.getelementbyid (" Ddlprovince "); prov.options.add (new option ("---Please select---", "")); var parray=zoneidprovince.split ("&"); for (Var i=0;i<parray.length;i++) { var idparray=parray[i].split ("#"); var szoneid=idparray[0]; var sprovince=idparray[1]; Prov.options.add (new Option (Sprovince,szoneid)); } 12. How to use prototype Ajax to submit data in a page (Java) step: in <head></head> Add the following JS file link code as follows: <head> <script language= "JavaScript" src= "/ndhotel/js/prototype-1.6.js" > </script> </head> Two: Put the prototype-1.6.js file in the/ndhotel/js/specified directory Three steps: <script type= "Text/javascript" ></ Script> declares the following calling function code as follows: <script type= "Text/javascript" > Function editipsegment () { var url= '/ Ndhotel/ipsegmentset.do?method=roomchangenotice '; var pars = ' startip= ' +startip+ ' &endip= ' +endip+ ' &lindex= '; New Ajax.request (URL, {method: ' Get ', Parameters:pars, asynchronous:false,oncomplete:editresult}); } function Editresult (result) { var returnstr = result.responsetext if (returnstr = = ' Fai L ') { alert (""); return false; }} </script> Four step: Implement background call code as follows: public Actionforward Roomchangenotice (A Ctionmapping mapping, actionform form, httpservletrequest request, httpservletresponse Response) throws Exception { String result = ""; PrintWriter pw = Rainprintwriter.getprintwriter (response); try { notifyservicetwo.sendmessage (4, 0); result = "success"; } catch (Exception E { logger.error ("Roomchangenotice" + e); } pw.write (result); Pw.close (); return null; &NBSP} 13.js to get the value of the form: the code is as follows: document.getElementById ("Lindex"). Value document.all.lindex.value// Lindex must be unique on the page //Set Get focus document.getElementById ("Lindex"). Focal () Document.all.startip.focus () // Setting loses focus document.getElementById ("Lindex"). Blur () Document.all.startip.blur () 14. Add/Remove rows in a table dynamically Code as follows: <table width= "100%" id= "Tdsearch" name= "Tdsearch" cellpadding= "0" cellspacing= "0" align= "center" > </table> //dynamically generating table's row var autoid = 0; Self-adding variable function addrow (value1,value2) { var Highquery=document.getelementbyid (" Tdsearch "); highquery.insertrow (); var NewRow = highquery.rows[highquery.rows.length-1]; newrow.id = "Row_" + autoid; newrow.insertcell (); newrow.cells[0].innerhtml = " <input width= ' value= ' "+value1+" ' onchange= ' Changeip ("+autoid+") ' type= ' text ' id= ' bipfrom_ ' +autoid+ "' >-"; newrow.insertcell (); newrow.cells[1].innerhtml = "<input width= ' value= '" +value2+ " Type= ' text ' id= ' bipto_ ' +autoid+ ' > '; var cell2 = Newrow.insertcell (); cell2.innerhtml = "<input c lass= ' Btn_1word ' type= ' button ' class= ' Hq_button ' value= '-' onclick=removerow ' (' + newrow.id + ' ') >; cell2.setattribute ("Class", "YellowCell2"); autoId=autoId+1; } function Removerow (rowId) { var Trrow = document.getElementById (rowId); //alert (Trrow);   ;//if (rowid!= "Row_0") { Trrow.removenode (true); //}} 15. Collection Code as follows://Show import progress bar document.all ("Btnimport"). Disabled=true; document.all("Datagrid_waitdiv"). style.left=100; document.all ("Datagrid_waitdiv"). style.top=295; document.all ("Datagrid_waitdiv"). Style.display = ""; form1.action= "/ndhotel/jsp/systemset/roomset/uploadfile.jsp"; Form1.submit (); 16. Create a new Window function Layer1addgroup () {var url= '/ndhotel/jsp/systemset/roomset/addgroup.jsp '; var newwin= window.showModalDialog (Url,window, "Dialogwidth=470px;dialogheight=400px;scroll =yes;status=no;help=no;");} //Refresh parent page function Roommainleftrightframe () {var layer= ' <%=layer%> '; Window.parent.parent.frames (' View '). location.href= "/ndhotel/troom.do?method=roomsetleftmenu&layer=" +layer; } 17. Set text box read-only property/ Set the color/settings for the text box radio check code as follows: document.all ("Txt_autotime"). Readonly=true; document.all ("Txt_autotime"). style.backgroundcolor= "#d0d0d0"; Runparamsetform.radnotforcibly.checked=true; //IP Address validation function Ipcheck (ipvalue) { var reg =/^/d{1,3} (/./d{1,3}) {3}$/; if (Ipvalue!= "") {&nbs P if (Reg.test (Ipvalue)) {  var ary = Ipvalue.split ('. '); for (key in ary) { if (parseint (Ary[key]) > 255) return false; &NB SP;} return true; }else return false; }else return true; }