{"id":7676,"date":"2021-04-12T22:57:28","date_gmt":"2021-04-13T03:57:28","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=7676"},"modified":"2021-04-12T22:58:02","modified_gmt":"2021-04-13T03:58:02","slug":"jquery-finding-a-set-of-checkboxes","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=7676","title":{"rendered":"JQuery &#8211; Finding a set of checkboxes"},"content":{"rendered":"\n<p>A corollary to my <a href=\"https:\/\/www.rushworth.us\/lisa\/?p=7672\" data-type=\"post\" data-id=\"7672\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript modifying checkbox values when the box is checked or unchecked<\/a> &#8230; I needed a way to reset the form (in my form, the default is for the boxes to be checked and the value to be 1). The following code identifies all checkboxes with a particular class, checks them, and sets the value to 1. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n\/**\n * This function checks off each checkbox of the input class\n *\n * @param {string} strCheckboxClass     Name of class identifying in-scope checkboxes\n * @return {null} \n *\n * @example\n *\n *     checkAllDatabases (&#039;MyBoxes&#039;);\n *\/\n function checkAllDatabases(strCheckboxClass){\n    arrayCheckboxes = $(&#039;.&#039;+strCheckboxClass);\n    for(i = 0; i &lt; arrayCheckboxes.length; i++) {\n        $( &#039;#&#039;+arrayCheckboxes&#x5B;i].name).prop( &quot;checked&quot;, true );\n        $( &#039;#&#039;+arrayCheckboxes&#x5B;i].name).val(1);\n    } \n}\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>A corollary to my JavaScript modifying checkbox values when the box is checked or unchecked &#8230; I needed a way to reset the form (in my form, the default is for the boxes to be checked and the value to be 1). The following code identifies all checkboxes with a particular class, checks them, and &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[765,856,854,1329],"class_list":["post-7676","post","type-post","status-publish","format-standard","hentry","category-coding","tag-html","tag-javascript","tag-jquery","tag-web-coding"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7676","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7676"}],"version-history":[{"count":4,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7676\/revisions"}],"predecessor-version":[{"id":7681,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/7676\/revisions\/7681"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7676"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7676"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7676"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}