JS Features: Select All, pop-up dialog box, using JSON to transfer AJAX data; Do not want to write extra text, directly on the code:
<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <% @taglib prefix=" C "uri=" Http://java.sun.com/jstl/core "%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
/** * */function SelectAll () {var selectall = document.getElementById ("Checkall");
var Checkboxid = document.getelementsbyname ("Id_list");
if (selectall.checked = = True) {for (var i = 0; i < checkboxid.length; i++) {checkboxid[i].checked = true;
} else {for (var i = 0; i < checkboxid.length; i++) {checkboxid[i].checked = false;
}}/** * Bulk delete operation */function DeleteData () {var idlist = document.getelementsbyname ("Id_list");
var ids = "";
var doctitles = ""; Check to see if the content is selected for (i = 0; i < idlist.length i++) {if (idlist[i].checked) {var temp = Idlist[i].value.split (";")
;
IDS + + temp[0] + ",";
Doctitles + = temp[1] + ","; } if (ids = = "") {alert ("") please select a record.
"); else {$.post ("/weibowidget.do?action=delete&" + New Date (), {' IDs ': IDs, ' Doctitles ': Doctitles}, Fun
Ction (data) {window.location.href = "/weibowidget.do?action=show";
return false;
}); }/** * Closes the window while emptying the From form content/functionClosewin () {///Initialize edit form $ ("#win_action"). Val ("");
Set Edit ID $ ("#win_id"). Val ("");
Set name $ ("#win_docTitle"). Val ("");
Set UID $ ("#win_uid"). Val ("");
$ ("#dialog_weibo"). Hide ();
/** * Save added or edited data */function Save () {//validate var DocTitle = $ ("#win_docTitle") before saving. Val ();
var uid = $ ("#win_uid"). Val ();
if (DocTitle!= "" && uid!= "") {$.ajax ({dataType: ' json ', type: ' POST ', url: '/weibowidget.do '), Data: {' action ': $ (' #win_action '). Val (), ' ID ': $ ("#win_id"). Val (), ' DocTitle ': $ ("#win_docTitle"). Val (
), ' UID ': $ ("#win_uid"). Val (),}, Success:function (data) {if (Data.flag = 1) {alert (data.msg);
Window.location.href = "/weibowidget.do?action=show";
else {alert (data.msg);
return false; Error:function () {alert ("Failed to save data due to a network problem").
");
return false;
}
}); } else {alert ("Name and ID cannot be empty.)
");
return false; }/** * Verify that the window is open * @param opertype * @returns {Boolean} */function Checkingisopenwin (opertype) {var deiplay = $ ("#dialog_weibo"). CSS ("display"); if ("block" = = Deiplay) {if ("addoper" = Opertype) {Alert (Add window is open.)
");
else if ("editoper" = Opertype) {alert ("edit window is open!");
return false;
return true;
//Open Add Window function Openaddwin () {if (Checkingisopenwin ("Addoper")) {$ (' #win_Title '). Text (' Add ');
$ ("#win_action"). Val (' Add ');
$ ("#win_docTitle"). Val ("");
$ ("#win_uid"). Val ("");
$ ("#dialog_weibo"). Show ();
return false; //Open edit window function Openeditwin (ID) {if (Checkingisopenwin ("Editoper")) {$.ajax {dataType: "JSON", type: "
POST ", url:"/weibowidget.do?action=ajaxloadweibo ", data: {' id ': id}, Success:function (data) {
if (Data.flag = = 1) {//Initialize edit form $ ("#win_action"). Val (' modify ');
$ (' #win_Title '). Text (' edit ');
$ ("#win_id"). Val (data.id);
$ ("#win_docTitle"). Val (Data.doctitle);
$ ("#win_uid"). Val (Data.uid); Show edit Window $ ("#dialOg_weibo "). Show ();
else {alert (data.msg);
return false; Error:function () {alert ("temporarily unable to modify the operation due to a network problem, please try again later.")
");
return false;
}
});
return false;
/** * Reset Search input/function ResetData () {$ ("#docTitle"). Val ("");
$ ("#uid"). Val ("");
Reprint please specify the Source: Http://blog.csdn.net/yangkai_hudong