Home  >  Article  >  Web Front-end  >  jquery.alert pop-up check box implementation code_jquery

jquery.alert pop-up check box implementation code_jquery

WBOY
WBOYOriginal
2016-05-16 18:51:331587browse

//jQuery Alert Dialogs Plugin Version 1.0
//Plug-in download address: http://abeautifulsite.net/notebook/87
The original method of itself is:

Copy code The code is as follows:

// Usage:
// jAlert( message, [title, callback] )
// jConfirm( message, [title, callback] )
// jPrompt( message, [value, title, callback] )
1. Add a new public method of multicheckbox:
// Public methods
multicheckbox : function (message, value, title, callback) {
if (title == null ) title = 'multicheckbox ';
$.alerts._show(title, message, value, ' multicheckbox ', function (result) {
if (callback) callback(result);
});
},

2. In private method _show : Add control to multicheckbox in function (title, msg, value, type, callback){...}:
// Private methods
------------ ------------Key part-----------------------------
case 'multicheckbox ' :
$("#popup_message" ).append(value).after(' ');
var $spanHover = $("#dialog span" );
$spanHover.hover(
function () {$(this ).addClass("spanmousehover" );},
function () {$(this ).removeClass("spanmousehover" );}
);
$("#checkall" ).click(function () {
if ($("#checkall" ).html() == "Select All" ) {
$("#dialog input" ).each(function () {$(this ).attr("checked" , true );});
$("#checkall" ).html("Cancel all Select" );
}
else {
$("#dialog input" ).each(function () {$(this ).attr("checked" , false);});
$("#checkall" ).html("Select All" );
}
});
$("#delcheckall" ).click(function () {
$(" #dialog input" ).each(function () {$(this ).attr("checked" , false );});
});
$("#popup_ok" ).click(function ( ) {
var getAll = "";
var test = $('#dialog input' ).each(function () {if (this .checked) {getAll = $(this ).val() ' ,';}});
var valback = getAll.substring(0, getAll.length - 1);//Remove the last ',' number
$.alerts._hide();
$ ("#ctl00_ContentPlaceHolder_main_TextBox_recever_sel" ).blur();
if (callback) callback(valback); // Return all selected content to the input box after clicking OK
});
$("#popup_cancel" ).click(function() {
$.alerts._hide();
$("#ctl00_ContentPlaceHolder_main_TextBox_recever_sel" ).blur();
if (callback) callback(null );
});
/ /---------------------------------------- ----------------------------------
Add the following name to // Shortuct functions:
jMulticheckbox = function (message, value, title, callback) {
$.alerts.multicheckbox(message, value, title, callback);
};
3. In the input input box of the previous code (or asp:TextBox) call the following script in the onfocus attribute:
jMulticheckbox('' , '<% = allcheckinfo.ToString() %> ' , 'Please select the receiving department' , function (r ) {
// Define the incoming html element, the main title of the pop-up box, the callback result (that is, the selected content)
if (r!=null )
$('#ctl00_ContentPlaceHolder_main_TextBox_recever_sel' ).val(r ; allinfo.Append("
" );
...
while (OracleDataReader.Read())
{
string bumeninfo = oradr[0].ToString();
allinfo.Append("
" );
}
...
allinfo.Append("
" );
Return
...
to JS, the final effect is as follows:

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn