0
I have a form where the user when filling, appears automatically in a div, as occurs here on the site. In text field I can pick up normally, but as I would to pick up from a combobox?
See below the code of the text field I started making, but need for the combobox:
HTML
<input name="Nome" id="nome" type="text" class="md-form-control responsavel required">
<!-- Aqui mostra o que foi digitado no campo acima -->
<p id="paragrafonome"></p>
The combobox I need to get is this:
<select name="Estado" id="estado">
<option value="RJ">Rio de Janeiro</option>
<option value="SP">São Paulo</option>
<option value="MG">Minas Gerais</option>
</select>
<p id="paragrafoestado"></p>
Jquery
// campo texto
var nome = document.querySelector('#nome');
var paragrafoNome = document.querySelector('#paragrafonome');
nome.addEventListener('keyup', function () {
paragrafoNome.innerHTML = "<div align='left' style='padding: 10px'><h3>" + nome.value + "</h3></div>";
});
// Combobox
var estado = document.querySelector('#estado');
var paragrafoEstado = document.querySelector('#paragrafoestado');
estado.addEventListener('keyup', function () {
paragrafoEstado.innerHTML = "<div align='left' style='padding: 10px'><h3>" + estado.value + "</h3></div>";
});
Question is tagged with tag
jquery
but you’re not using jquery anywhere. You expect an answer with jQuery or without?– fernandosavio
That’s pretty confusing, you mention combobox, but your example is listening to the keyup of and a input type text.. should not be a select???
– Ricardo Pontual
really is quite confusing. Where are the data coming from? In what format?
– Jorge.M
You’re right. I’m sorry. I adjusted my post, see if it got better?
– user24136
Hello. You have Jquery according to the cited example.
– user24136
I’m sorry for the ignorance, but I read your code 3x and saw only pure Javascript.. no jQuery
– fernandosavio
True Fernando. It’s javascript. I fixed the tag.
– user24136