-2
I have input in html
<input value ="Get" onClick={GetSelected} type="checkbox" value="SLA contratual" />
when clicked a span is added to a list
<li id="teste"></li>
I need to remove if clicked on the input again, but I’m not getting it. Follow the script
function GetSelected() {
var selected = new Array();
var p = document.getElementById("teste");
var portfolio = document.getElementById("section");
var chks = portfolio.getElementsByTagName("INPUT");
var span = document.createElement("span");
for (var i = 0; i < chks.length; i++ ) {
if (chks[i].checked) {
selected.push(chks[i].value);
}
};
if (selected.length > 0) {
console.log("Você selecionou: " + selected.join(", "));
span.innerHTML = selected.join(", ");
p.appendChild(span);
}
};
It’s just an input checkbox or multiple?
– Sam
are several, each within a list
– PAOLA SANTOS