Last active
August 29, 2015 14:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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