Closed . This question needs details or clarity . It is not currently accepting answers.
If what you're looking to do is disable any other elements that have the same className than you need to update your if statement a bit. You're checking only the element that was passed into the function when I think you mean to do a comparisson of the element that was checked with all other elements className.
function ckChange(el) {
var ckName = document.getElementsByTagName("input");
for (var i = 0, c; (c = ckName[i]); i++) {
console.log(el.className)
if (ckName[i].type == "checkbox" && ckName[i].className === el.className) {
c.disabled = !(!el.checked || c === el);
}
}
}
Here's a functioning codepen: https://codepen.io/orunnals/pen/qBEabgq
[PDF] use classes order, A1 (Shops). Shops, retail warehouses, hairdressers, undertakers, travel and ticket agencies, post offices, pet shops, sandwich bars, showrooms, domestic hire � Go to the Lists menu, then select Classes. Select Create (+). Enter the class name. If it's a subclass, select the Subclass of checkbox and find the class it's under in. Select OK to add it. Use class tracking. You can assign a class to the following transactions: Invoice; Sales receipt; Estimate; Sales order; Statement Charges; Refunds and credits; Check
You can group elements with the same class name and then, when a checkbox is checked, disable all the elements in its group.
Here is an example:
const groupClasses = ['9AM', '10AM', '11AM'];
const groups = groupClasses.map((cls) => {
const elms = document.getElementsByClassName(cls);
return Array.from(elms);
});
groups.forEach((group) => {
group.forEach((elm) => {
elm.addEventListener('change', () => {
group.filter(e => e !== elm).forEach((e) => {
e.disabled = elm.checked;
});
});
});
});
<tr>
<td><input class="9AM" data="9AM" type="checkbox" name="" id="progress1" value="1" tabIndex="1">9AM</td>
</tr>
<tr>
<td><input class="9AM" data="9AM" type="checkbox" name="" id="progress2" value="1" tabIndex="1">9AM</td>
</tr>
<tr>
<td><input class="10AM" data="10AM" type="checkbox" name="" id="progress3" value="1" tabIndex="1">10AM</td>
</tr>
<tr>
<td><input class="10AM" data="10AM" type="checkbox" name="" id="progress3" value="1" tabIndex="1">10AM</td>
</tr>
<tr>
<td><input class="11AM" data="11AM" type="checkbox" name="" id="progress4" value="1" tabIndex="1">Test 4</td>
</tr>
<tr>
<td><input class="11AM" data="11AM" type="text" name="" id="progress4" tabIndex="1">Input</td>
</tr>
Planning use classes in England, On Tuesday the government laid before Parliament regulations making sweeping changes to the Use Classes Order. The changes, which� The HTML class attribute specifies one or more class names for an element. Classes are used by CSS and JavaScript to select and access specific elements. The class attribute can be used on any HTML element. The class name is case sensitive. Different HTML elements can point to the same class name.
check current element class with all other class
ckName[i].className === el.className
<script>
function ckChange(el) {
var ckName = document.getElementsByTagName('input');
for (var i = 0, c; c = ckName[i]; i++) {
// console.log(ckName[i]);
if (ckName[i].type == "checkbox" && ckName[i].className === el.className) {
ckName[i].disabled = true;
//c.disabled = !(!el.checked || c === el);
}
}
}
</script>
<tr>
<td><input class="9AM" data="9AM" type="checkbox" name="" id="progress1" value="1" tabIndex="1" onClick="ckChange(this)">9AM</td>
</tr>
<tr>
<td><input class="9AM" data="9AM" type="checkbox" name="" id="progress2" value="1" tabIndex="1" onClick="ckChange(this)">9AM</td>
</tr>
<tr>
<td><input class="10AM" data="10AM" type="checkbox" name="" id="progress3" value="1" tabIndex="1" onClick="ckChange(this)">10AM</td>
</tr>
<tr>
<td><input class="10AM" data="10AM" type="checkbox" name="" id="progress3" value="1" tabIndex="1" onClick="ckChange(this)">10AM</td>
</tr>
<tr>
<td><input class="11AM" data="11AM" type="checkbox" name="" id="progress4" value="1" tabIndex="1" onClick="ckChange(this)">Test 4</td>
</tr>
<tr>
<td><input class="11AM" data="11AM" type="text" name="" id="progress4" tabIndex="1" onClick="ckChange(this)">Input</td>
</tr>
COVID-19 UK: Use Classes Order, Use Class. Use. Permitted Change. A1 Shops. Shops, retail warehouses, post offices, ticket and travel agencies, sale of cold food for consumption off premises,. TCPA (USE CLASSES) ORDER 1987 (AS AMENDED) (LAST AMENDED BY THE TCPA (USE CLASSES) (AMENDMENT) (ENGLAND) ORDER 2016) USE / DESCRIPTION OF DEVELOPMENT PERMITTED CHANGE A1 (Shops) Retail sale of goods to the public – Shops, post offices, travel agencies and ticket agencies, hairdressers, funeral directors and undertakers, domestic hire
[PDF] Guide to Use Classes Order in England, What are use classes? Most land and buildings in England are categorised depending on their purpose or use and these categories are set out by the use class� Definition and Usage The.class selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class.
Use classes explained, If you specify the service class itself as the provider token, the default behavior is for the The provider-definition key can be useClass , as in the example. Class variables − Class variables are variables declared within a class, outside any method, with the static keyword. A class can have any number of methods to access the value of various kinds of methods. In the above example, barking (), hungry () and sleeping () are methods.
Dependency providers, From 1st September use classes A1 (Shops), A2 (Financial and professional services), Class A3 (Restaurants and cafes), and Class B1 (� Use Class Use Permitted Change. A1. Shops. Shops, retail warehouses, post offices, ticket and travel agencies, sale of cold food for consumption off premises, hairdressers, funeral directors, hire shops, dry cleaners, internet cafes Temporary permitted change (3 years) to A2, A3, B1, public library, exhibition hall, museum, clinic or health centre (interchangeable with notification) Permitted change of A1 or mixed A1 and dwellinghouse to C3 (subject to prior approval) (see also 2018 Order)
Comments this is way too less information. How should the checkboxes behave exactly? Whatever you want to do, you'll probably find document.getElementsByClassName()
and/or document.querySelectorAll()
useful. Thanks so much for taking the time to help! Learned a lot here. Great! If my answer was what you were looking for please accept it as the answer. Thanks! This is doing exactly what his code do.. Did you run the code Snippet on his? @GustavoAGarcia No it is not, my snippet only disables checkboxes that have the same class as the clicked one, the OP's disables all of them.