Skip to content

Instantly share code, notes, and snippets.

@Rodrigo54
Last active August 29, 2015 14:21
Show Gist options
  • Save Rodrigo54/eca318c7edda070c6a43 to your computer and use it in GitHub Desktop.
Save Rodrigo54/eca318c7edda070c6a43 to your computer and use it in GitHub Desktop.
função que insere uma certa quantidade de elementos numa div a partir de um input
function qntprovas(tam) {
var tam, i, x;
//aki d recebe a div onde ficara os input's
var d = document.getElementById("provas");
//aki um texto é exibido na div#qnt com a quantidade selecionada no input
document.querySelector('#qnt').innerHTML = tam + " provas";
//aki todos os elementos dentro da div são removidos
while (d.firstChild) {
d.removeChild(d.firstChild);
}
//aki são definidos a quanntidade de input's
for (i = 0; i < tam; i++){
x = document.createElement("INPUT");
x.setAttribute("type", "file");
x.setAttribute("name", "userfile[]");
//aki os input's são colocados na div#provas
d.appendChild(x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment