How do I return items related to the one selected in the selectbox?

0

My problem is to return values related to the element that I chose in the select box. To contextualize: I have a set of cities and these cities have related items to them. I need to return only the items attached to it when selecting a city. The part of checking these items is already working, but it's being on every item.

$(function() {
	list = [];
  total = document.getElementById('total');
  //media = parseFloat(document.getElementById('media').value);
  $(document.getElementsByName('p')).bind('click', function() {

    var valTotal = total.value;

    valTotal = parseFloat(valTotal.replace(',', '.'));

    var valInput = (this.value);
    list.push(valInput);
    valInput = parseFloat(valInput.replace(',', '.'));

    
    var value = (this.checked) ? parseFloat((valTotal + valInput)) : parseFloat((valTotal - valInput));
    total.value = value;
    var valores = total.value;
    t_lista = list.length;
    media = parseFloat(valores)/t_lista;
    document.getElementById("medias").innerHTML = media;
    alert(media);
    
  });

});

 <div class="col-md-12 col-sm-12" ng-app="">
  	<!-- <div class="col-md-6 col-sm-6" id="map-canvas"></div> -->
  	<div class="col-md-12">
  		<h3>Valores dos ítens selecionados</h3>
  		R$ <input type="text" size="4" name="total" id="total" value="0,00" />
	  </div>	

	  <div class="col-md-12">
  		<h3>Média dos Valores dos ítens selecionados</h3>
  		R$ <p id="medias" ></p>
	  </div>	

  	<div class="col-md-12 col-sm-12" ng-model="products">
  		{{ids}} registros<br />
  		<div id="receberLink"></div>
  		<ul class="list-group">
	  		{% for i in obj %}

	  			<div class="col-md-12 checkbox">
	  			<li class="list-group-item"><input type="checkbox" name="p" class="valores" class="w3-check" id='p' value="{{i.valUltimaVenda}}">
	  			{{i.dscProduto}} R$ {{i.valUltimaVenda}} Em <b>{{i.nomMunicipio}}</b></li>
	  		</div>
	  		{% endfor %}
	  	</ul>	
  	</div>

  </div>

The tags {{}} and {%%} are from django.

    
asked by anonymous 23.06.2018 / 17:27

0 answers