0
I have the problem to recover 2 values and send by load. I can recover the data from the data attribute link but the input I can’t recover to concatenate with the data and do the right thing. Follows the code.
Javascript:
$('.buscarr').click(function() {
var id = $(this).attr('campo1');
var id2 = $(this).attr('data');
alert(id);
console.log(id);
console.log(id2);
$("#cliente1").load($(this).attr(id2 + id));
});
HTML:
<div class="form-group">
<label for="busca">Nome Servico*:</label> <input id="campo1" type="text" class="form-control" placeholder="Insira um nome para busca">
</div>
<a href="#" data="/wbahd/servico_servlet?acao=buscar&busca=" class="btn btn-default btn-cadastrar-btn buscarr">Buscar</a>
</div>
I don’t understand, if you already know the
id
, why seek the value ofid
? What you intend to store here:var id = $(this).attr('campo1');
?– BrTkCa
the value of the field is concatenate with another value.
– junio
But here var id = $(this). attr('campo1'); does not return me anything.
– junio
It returns nothing because
attr
search for an element attribute, andbuscarr
doesn’t have it.– BrTkCa
I had tried with attribute tmb is nothing , then I returned to id. Continues returning me 'Undefined'.
– junio
Obg was able to recover the id value but I can’t load concatenating $("#cliente1"). load($(this).attr(id2+id)); sera pq ?. I’m trying.
– junio