Jump to content

Adicionar novo campo


Inferi
 Share

Go to solution Solved by HappyHippyHippo,

Recommended Posts

Bom dia, tenho um formulário onde preciso de inserir novos campos carregando numa imagem.

Tenho o código montado, e está a adicionar os campos na zona correcta, mas se o primeiro tiver dados, quando adiciono outro, os dados limpam automaticamente.

Código Javascript


fields = 0;
function addInput() {
if (fields != 4) {
document.getElementById('dynamicInput').innerHTML += "<input type='text' size='25' maxlength='35' name='PagPessoal[]' class='fonttxt'><br>";
fields += 1;
} else {
alert ("Apenas são permitidas 5 páginas pessoais.");
document.ajaut.add.disabled=true;
}
}
[/Code]

Código HTML do formulário

[Code=html]
<td align="left" id="dynamicInput">
<table>
<input type="text" size="25" maxlength="35" name="PagPessoal[]" class="fonttxt">
<img class="add" src="images/add.png" style="cursor: pointer;" onclick="addInput('dynamicInput');" height="15" width="15">
</table>
</td>
[/Code]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.