jquery1 (Select All, to submit data)

2009-11-06  来源:本站原创  分类:Web  人气:232 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
 <!--    Introduce jQuery  -->
 <script src="../scripts/jquery-1.3.1.js" type="text/javascript"></script>
 <script type="text/javascript">
$(function(){
     // Select all
     $("#CheckedAll").click(function(){
                        // All checkbox followed all selected checkbox walk  .
                        $('[name=items]:checkbox').attr("checked", this.checked );
         });
         $('[name=items]:checkbox').click(function(){
                                // Define a temporary variable  , Avoid repeating the same selector to select elements in the page  , Improve the efficiency of the program  .
                                var $tmp=$('[name=items]:checkbox');
                                // Use the filter method to filter for a selected check box  . And directly to CheckedAll assignment  .
                                $('#CheckedAll').attr('checked',$tmp.length==$tmp.filter(':checked').length);

                        /*
                                // Line do too many things you need to write more comments  . A complex selector might also affect efficiency  . It is not recommended that the following wording  .
                                $('#CheckedAll').attr('checked',!$('[name=items]:checkbox').filter(':not(:checked)').length);
                        */
         });
          // Output values
        $("#send").click(function(){
                var str=" You selected the  :\r\n";
                $('[name=items]:checkbox:checked').each(function(){
                        str+=$(this).val()+"\r\n";
                })
                alert(str);
        });
});
  </script>
</head>
<body>

<form method="post" action="">
    Do you like sport is  ?<input type="checkbox" /> Select all  / Check  <br/>
    <input type="checkbox" name="items" value=" Football  "/> Football
        <input type="checkbox" name="items" value=" Basketball  "/> Basketball
        <input type="checkbox" name="items" value=" Badminton  "/> Badminton
        <input type="checkbox" name="items" value=" Table tennis  "/> Table tennis  <br/>
        <input type="button" value=" Submit  "/>
</form>

</body>
</html>
相关文章
  • jquery1 (Select All, to submit data) 2009-11-06

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

  • The client to submit data encoding format 2010-03-30

    The client to submit data to the service, there are two methods GET and POST 1.get way data directly in the url on the stitching, the use of &-separated key-value pairs. However, sometimes key, value will appear in Chinese and other standards for htm

  • Clients submit data encoding format 2010-03-30

    The client to submit data to the service in two ways GET and POST 1.get way <br /> data directly in the url on splicing, using the &-separated key-value pairs. However, sometimes key, value will appear in Chinese and other standards for unsafe c

  • Run dry backfill multiple sources report: Rapid multi-multi-table database to submit data 2011-04-11

    Dry Run report development using web-based data reporting module will always encounter data submission program. Submitted to the complexity of the program, depending on the complexity of the input page. The most simple one page a record, correspondin

  • Run dry backfill multi-source reports: Rapid multi-multi-table database to submit data 2011-04-11

    Run dry report development using web-based data reporting module will always encounter data submission program. Submitted to the complexity of the program, depending on the complexity of the input page. The simplest one page a record, corresponding t

  • Volume on the page to submit data 2010-03-31

    On the page, and try not to write Java code . You can sometimes in order to implement certain specific features also had to write something <> For example, in the batch data, the page can compute . <%for(int i=1;i<=7;i++){ %> <tr> <

  • Ext several practical ways to submit data 2010-05-06

    (A), the form will be submitted to the form ordersForm.getForm (). submit ((/ / client data to the server url: 'inBoundUpdateInorderAction', params: ("jsonStr": jsonStr, "inOutOrderDateId": inOutOrderDateId, "inOutOrderId": i

  • How to submit data in the grid 2010-11-16

    First, all data submitted Ext.grid.GridPanel 1, front desk operations function saveOperatorFunExt () { var store = funExt_grid_center.getStore (); / / Array of data into another var selFuns = []; store.each (function (rec) { selFuns.push (Ext.util.JS

  • used in the struts framework jquery AJAX, json data format to submit data that 2010-12-31

    This demo shows the main use of jquery's ajax, using the struts2 framework, json data format, so in addition to import the necessary jar struts2 package, the package had to plug into json. 1. First create a form. <form action="" method="

  • ajax to submit data (agent function) 2009-04-04

    ajax submit / / 1. To determine whether the user for the landing function isLogin (url, page) ( try ( var a = new MyAjax (); var u = <% = request.getContextPath ()%>/ LoginAction.do? action = unLogin; var queryString = "validateCode ="+_$(

  • jquery using $. ajax post method to submit data 2010-04-17

    $.ajax({ type: "POST", dataType:"json", // If the returned data is the JSON format ,dataType Please specify json url: "inputCodeAction", data: "dictType=" + $(this).attr("dictType") + "&inputText=

  • JSP page refresh submit data duplication solution summary 2010-07-01

    jsp page: <% @ Page contentType = "text / html; charset = gbk"%> <% @ Page language = "java"%> <% @ Page import = "java.util .*"%> <% response.setHeader ("Cache-Control", "no-cache");

  • Select the appropriate Boolean data type for MySQL 2011-04-08

    In the MySQL database, how do you achieve True / False field do? There are several types: 1. ENUM enum For example: ENUM ('F', 'T'), ENUM ('N', 'Y'), ENUM ('0 ', '1'). MySQL database user table system is used in this way, simple and intuitive, only t

  • JSP submit data encoding twice decoding two garbage 2010-04-08

    document.getElementById ("listDate"). src = encodeURI ( encodeURI ("<%= request.getContextPath ()%> / qxglDetail.action? m = queryQxglDetailData "+ url) ); ************************************************** **********************

  • php form security. submit data filtering 2011-01-09

    PHP form submission to the special character of the filtration and treatment http://www.bestlovesky.com/read.php?1002 php form submission security procedures http://wenku.baidu.com/view/73b54729647d27284b73513a.html php form validation filter class h

  • Using jQuery to achieve submit form data asynchronously 2010-08-18

    The traditional form form as follows: <form name="input" action="recv.cgi" method="post"> Username: <input type="text" name="user" /> <input type="submit" value="Submit"

  • How to achieve JS List list box, select the number of bulk data deletion 2010-04-26

    How to achieve JS List list box, select the number of data bulk delete, the following code just click the checkbox Chufa the method of this are, each data of the ID, packaged inside the array, the background loop by parsing the array id delete: var d

  • SQL select max each data 2011-06-02

    A data table has the following data: The first column is the number, the second column is the content, the third column is the time F183S-T0201 9998 4/26/2006 5:11:50 PM F183S-T0201 9998 4/29/2006 5:14:04 PM F183S-T0201 9998 4/30/2006 5:18:23 PM F183

  • jQuery Form Plugin (a): Form to submit a form using AJAX 2011-01-06

    JQuery Form plug-in allows you to easily use AJAX to submit Form form, the main method and ajaxSubmit ajaxForm form elements responsible for the collection of information, management submitted to the process. Both are configurable, giving you ultimat

  • JS can be used to submit a list of flip 2010-05-09

    Action: public class JavaScriptArrayAction extends DispatchAction{ public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { HttpSession session = request.getSession(true); JavaScr