1
I have a problem with "how" to show the values received by the onClick event in the checkbox field, which are stored in an array. Every click on a checkbox stores its id in the array.
I can show all the values together while the user clicks on the checkbox using push, however I wanted to show them in separate lines and push would not serve in this case, tried some other ways and continues without the desired result.
function disciplina_escolhida(){
var disciplina = [];
$('#disciplina :checked').each(function () {
disciplina.push($(this).val());
$('#listas').append('<div><input type="text" name="campo" value='+disciplina+' disabled style="cursor:pointer"></div>');
});
}
The code so far is this.
EDIT: My doubt is/was, as I should do to show separately the values that are stored in the Checkbox array, because every time someone clicks on a Checkbox, the values/names already selected previously, are added together with the new, making all values stick together on a single line, which was not the intention when showing the data of the same.
@Lienfeng your question is a little confused, please read the community guidelines on how to make a good question. Once you make the change and explain the situation better, giving examples, codes among other users and even I will be able to help you.
– user148754
The
push
serves for you to insert elements in the array, not to make displays. Can explain your problem better?– GustavoAdolfo
Yes, about the push I expressed myself erroneously, but it was "this" even my problem, has already been answered but I will try to edit and leave in a more succinct way.
– LinFeng