How do I make a "+" button add new fields to a form? I even found a way to do it, but it is bugged and I do not know how to solve it.
var cont = 1;
function newContest(){
var c1 = '<td align="center"><select name="SITE_ID"><option value="1">CD-MOJ</option><option value="2">SPOJ-BR</option><option value="3">SPOJ-WWW</option></select></td>'
var c2 = '<td align="left" id="siteID"><input type="text" name="ID_SITE"></td>'
var c3 = '<td align="left" id="NOME_COMPLETO_SITE"><input type="text" name="NOME_COMPLETO_SITE"></td>'
var c4 = '<td align="left" id="NOME_PEQUENO"><input type="text" name="NOME_PEQUENO" size="1" value=A></td>'
document.getElementById('NovoCampo1').innerHTML+= c1;
document.getElementById('NovoCampo2').innerHTML+= c2;
document.getElementById('NovoCampo3').innerHTML+= c3;
document.getElementById('NovoCampo4').innerHTML+= c4;
cont++;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form>
<fieldset id="Contest_ID">
<legend>Novo Contest</legend>
<table>
<tr>
<td align="left">Site ID:</td>
<td align="center">
<select name="SITE_ID" id="SITE_ID" >
<option value="1">CD-MOJ</option>
<option value="2">SPOJ-BR</option>
<option value="3">SPOJ-WWW</option>
</select>
</td>
<td align="left"><input type="text" id="ID_SITE"></td>
<td align="left"><input type="text" id="NOME_COMPLETO_SITE"></td>
<td align="left"><input type="text" id="NOME_PEQUENO"value="A"></td>
<td align="left"><button type="button" id="botao" onclick="newContest()">+</button></td>
</tr>
<tr>
<td align="left"></td>
<td align="center" id="NovoCampo1"></td>
<td align="left" id="NovoCampo2"></td>
<td align="left" id="NovoCampo3"></td>
<td align="center" id="NovoCampo4"></td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
When I click the + button everything I wrote in the fields appears. Why is this happening and how can I resolve it?