Implementation Code of the jquery. alert pop-up check box

Source: Internet
Author: User

// JQuery Alert Dialogs Plugin Version 1.0
// Plug-in: http://abeautifulsite.net/notebook/87
The original method is as follows:
Copy codeThe Code is as follows:
// Usage:
// JAlert (message, [title, callback])
// JConfirm (message, [title, callback])
// JPrompt (message, [value, title, callback])
1. Add a 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 the private method _ show: Added multicheckbox control in function (title, msg, value, type, callback:
// Private methods
------------------------ Key part ------------------------------
Case 'multicheckbox ':
$ ("# Popup_message "). append (value ). after ('<div id = "popup_panel"> <span id = "checkall" style = "cursor: pointer; border: 1px solid # FFCC35; font-family:; font-weight: bold; background-color: # FFFF99; color: # 0000CC; margin: 3px; padding: 3px 10px 3px 10px; "> select all </span> <span id =" popup_ OK "style =" cursor: pointer; border: 1px solid # CF4342; font-family:; font-weight: bold; background-color: # DFF1FF; color: # CF4342; margin: 3px; padding: 3px 10px 3px 10px; "> OK </span> <span id =" popup_cancel "style =" cursor: pointer; border: 1px solid # CF4342; font-family:; font-weight: bold; background-color: # DFF1FF; color: # 0000CC; margin: 3px; padding: 3px 10px 3px 10px; "> cancel </span> </div> ');
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 ");
}
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 ','
$. Alerts. _ hide ();
$ ("# Ctl00_ContentPlaceHolder_main_TextBox_recever_sel"). blur ();
If (callback) callback (valback); // after you click OK, upload all the selected content back to the input box.
});
$ ("# 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. Call the following script in the onfocus attribute of the input box (or asp: TextBox) of the previous Code:
JMulticheckbox ('', '<% = allcheckinfo. ToString () %>', select the receiving department, function (r ){
// Define the input html element. In the pop-up box, the main title and callback result (that is, the selected content)
If (r! = Null)
$ ('# Ctl00_ContentPlaceHolder_main_TextBox_recever_sel'). val (r );
});
In this example, "allcheckinfo. ToString ()" can be used to retrieve the results from the corresponding business logic in the background, for example:
StringBuilder allinfo = new StringBuilder ("");
Allinfo. append ("<div id = \" dialog \ "style = \" padding: 0; margin: 0; height: 250px; width: 280px; text-align: left; line-height: 20px; overflow: auto \ "> ");
...
While (OracleDataReader. Read ())
{
String bumeninfo = oradr [0]. ToString ();
Allinfo. append ("<span class = \" spanmouse \ "> <input name = \" chk1 \ "type = \" checkbox \ "id = \" c "+ flag + "\ "value = \" "+ bumeninfo +" \ "/> <label for = \" c "+ flag +" \ ">" + bumeninfo + "</label> </ span> <br/> ");
}
...
Allinfo. Append ("</div> ");
Return <div>... </div> to JS. The final result is as follows:
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.