3
I need to get the name of checkbox selected as soon as I click one of the checkbox that exist on the page. The value I already got it, but I need to also take the value of name.
Could someone help me or give me another alternative because I need to take the value of name and value at the same time as clicking.
$(document).ready(function () {
		
	$('input[name="1117"]').click(function () { 
		selecionado('1117'); 
	}); 
	var selecionado = function (grupo) { 
		var result = $('input[name="' + grupo + '"]:checked'); 
		if (result.length > 0) { 
			var contador = result.length + " selecionado(s)<br/>"; 
			result.each(function () { 
				contador += $(this).val() + " "
			}); 
			$('#divFiltros').html(contador); 
		} 
		else { 
			$('#divFiltros').html("Nenhum selecionado"); 
		} 
	}; 
}); <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="divFiltros"></div>
<form method="POST"> 
      
      <legend>Marca</legend>
      
      <div class="checkbox checkbox-success">
           <input class="styled marca" type="checkbox" id="6327" name="1117" value="6327">
           <label for="">Samsung</label>
      </div>
      <div class="checkbox checkbox-success">
           <input class="styled marca" type="checkbox" id="6327" name="1117" value="6328">
           <label for="">Motorola</label>
      </div>
      <div class="checkbox checkbox-success">
           <input class="styled marca" type="checkbox" id="6327" name="1117" value="6329">
           <label for="">Sony</label>
      </div>
      <div class="checkbox checkbox-success">
           <input class="styled marca" type="checkbox" id="6327" name="1117" value="6330">
           <label for="">LG</label>
      </div>
      
      <legend>Especificação</legend>
      
      <div class="checkbox checkbox-success">
           <input class="styled marca" type="checkbox" id="450" name="1120" value="450">
           <label for="450">4G</label>
      </div>
      <div class="checkbox checkbox-success">
           <input class="styled marca" type="checkbox" id="455" name="1120" value="455">
           <label for="455">2 Chips</label>
      </div>
      <div class="checkbox checkbox-success">
           <input class="styled marca" type="checkbox" id="461" name="1120" value="461">
           <label for="461">Video 4K</label>
      </div>
</form>
Have you tried it with
this.nameinside the Event Handler?– Sergio
not yet...how would it be? I know a lot about Jquery, just a little bit of php
– Rodrigo Araujo
How you need to use the
name?– Sergio
Take a look here: https://jsfiddle.net/0y8heu9r/
– Sergio
Almost that...=) I need you to show them all at the same time, because when we click on Specifications some the Brand.... would have like to show everything together?
– Rodrigo Araujo
merged type show Brand and Specification in #divFilters
– Rodrigo Araujo
So you don’t need the
name, you want to fetch all marked inputs regardless of thename, that’s it?– Sergio
need the 2 because I need to use the 2 name and value to fetch the products according to the code of the specifications and the specification itself said.
– Rodrigo Araujo
EX: Brand id: 1117 Sansung id:6327, LG id:6328...
– Rodrigo Araujo
Specification id: 1120 - 4g id:450, 2chips id:455...
– Rodrigo Araujo
Okay, something like that: https://jsfiddle.net/0y8heu9r/1/ ?
– Sergio
ISSOOOOO.... SHOWWW
– Rodrigo Araujo
VERY GOOD....
– Rodrigo Araujo
Thank you Sergio that I really needed, God Bless!!!
– Rodrigo Araujo
You’re welcome, I’ll give you an answer to make it more complete.
– Sergio