Selecting groups containing the same brand

Hello,
<input type="radio" class="brand">
It works fine if there is a brand in each radio group
When one of the radio groups is clicked, the brands in other groups belonging to that brand are selected.no problem here

The problem is:
If there is more than one in a group of the same brand, it creates a problem.
There are two of each brand in the area shown in the red frame in the picture.

I want to disable the area indicated by the red frame
I want the other groups to be selected on a brand-based basis, but the red-framed area should only be selected manually.
Sometimes there are anomalies when I remove the class, what should be the correct code?

    $(document).on('change', "input[type='radio']", function(){    
    var name = $(this).attr('class');
    $("." + name ).screwDefaultButtons("check");
    });

Don’t use CLASS because that is more for your CSS. Place an ID in each of the radio and use that for your radio checks. This way, you can group them but leave the class however you want. Not sure if that is what you are asking.

Previously, I removed the class so that the red-framed area is not selected on a brand-based basis.
AND
Marking was delayed when manually selecting the red framed area and even though it was the same group, it was chosen more than once
I couldn’t understand why, I thought the coding was wrong
However, I’ve been trying for a few days now the previous problem does not exist as it works correctly I don’t know if it will be a problem later

My aim is
If there is more than one product group on a page, when any of them is selected, the same brand will be automatically selected from the other groups. good to save time

However, there may be more than one product from the same brand in a group on a few pages. These groups need to be selected manually, not by automatic selection.

If I use ID there will be more than one same ID on a page.?

Well, what I meant is the STYLING is handled thru the CSS which is assigned to the CLASS option.
Then, you can add a separate ID to make individual buttons separate and use that to code items as you need. You can also use the newer data options to group things. But, if it is working correctly now, I guess you solved it.

I didn’t do anything, I don’t know if the problem will repeat another time, I’m worried if this encoding is not correct
I don’t know what it takes for something like this

Hello again
There are two separate radio groups on another page
I can’t use “class”, “name”, and “id” tags to use above code
What else can I use?
Sample: data-value? as

Why can’t you use class? In HTML you can use more than one than one class. And, using PHP, you can insert extra classes where you need them. Then, in JS or JQuery, you can access the class as needed.
So, in HTML like this:

<input type="radio" class="radio111 some-other-class'>

You can have the first class be the actual CSS code for the button and the second one be a special class you are using in the JS code. I do not understand why you can not use class as the identifier…

Because when a brand in a group is clicked, it prevents choosing the same brand from the other group.
class “brand”
class “brand another-class”
Brand selection does not work when there is more than one css name in the class

There are two groups of radio buttons

//ajax_1.php
<input type="radio" name="first_group" class="brand">
<input type="radio" name="first_group" class="brand">
<input type="radio" name="first_group" class="brand">

<script>
	$(function(){
		$('input[name=first_group]').screwDefaultButtons({
			image: 'url("images/radioSmall.png")',
			width: 23,
			height: 23
		});

	});
</script>


// ajax_2.php
<input type="radio" name="second_group" class="brand">
<input type="radio" name="second_group" class="brand">
<input type="radio" name="second_group" class="brand">

<script>
	$(function(){
		$('input[name=second_group]').screwDefaultButtons({
			image: 'url("images/radioSmall.png")',
			width: 23,
			height: 23
		});

	});
</script>

radio buttons come to home page with ajax
No problems so far.

There is a checkbox with the same name on the Home Page

<input type="checkbox" name="first_group">

<input type="checkbox" name="second_group">

No style is required like ajax for radio and checkbox on homepage

When I use it this way, both the radio style and the checkbox style are mixed in the checkbox on the homepage and the checkbox is not used.

Since there is no class in the checkbox, I cannot select the brand when I use a class on the radio buttons.
It was very confusing, I hope I could explain

Couldn’t you just put each group into different DIV classes? And, you can do that for the AJAZ calls too.
Then, you can search for that DIV and then the class brand to get to whatever you need. This would keep the groups separated.

1 Like

It never occurred to me, this might be a solution :+1: :+1:

I have another question
I want to add the following code to the same brand selection code in other groups of the selected brand.
So, on every click/selection I want reset first then selection
The reason is I want to prevent the selection of different branded products.
Sample:
there are 4 groups
Let’s say there is AAA brand in all groups.
I chose this brand and the same brand was chosen in all groups.
No problem up here ok
Example 2nd group has FFF brand and let’s say I chose this brand.
Since there was no FFF brand in other groups, the previously selected AAA brand remained selected.
Here’s what I want to avoid

$('input:radio').screwDefaultButtons("uncheck");
$('input:radio').screwDefaultButtons("enable");

If there was a reset, he would have to choose from this group as well and different brand would prevent selection

Sponsor our Newsletter | Privacy Policy | Terms of Service