Estou fazendo uns testes aqui, mas estou com um pouco de dificuldade.
Atualmente o código para teste está assim:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript" type="text/javascript">
function campo(){
var x = 3;
if (x <= 10){
document.write ("<label for='op_"+x+"'>Opção 0"+x+": </label><input type='text' name='opcaoes' id='op_"+x+"' maxlength='100' /><br />");
x++;
}
}
</script>
<title>Testes</title>
</head>
<body>
<form name="enquete" id="enquete" method="post" action="enquete.php">
<label for="titulo">Título: </label>
<input type="text" name="titulo" id="titulo" maxlength="100" /><br />
<label for="pergunta">Pergunta: </label>
<input type="text" name="pergunta" id="pergunta" maxlength="100" /><br /><br />
<label for="op_01">Opção 01: </label>
<input type="text" name="opcoes" id="op_01" maxlength="100" /><br />
<label for="op_02">Opção 02: </label>
<input type="text" name="opcoes" id="op_02" maxlength="100" /><br />
<a href="java script: void(0);" onclick="campo();">Adicionar mais uma opção</a><br /><br />
<input type="submit" value="Criar Enquete" />
</form>
</body>
</html>
Quero que o novo campo apareça a cima do link, mas, para isso, não posso usar o document.write(). Como posso fazer isso?
O que pensei em fazer foi colocar uma div a cima do link, para fazer os novos campos apareceram dentro dela, mas como posso fazer com que os campos sejam exibidos dentro dessa div? Com que função?
O obejtivo é fazer algo parecido ao formulário de enquete aqui do fórum (do IPB). Fui olhar no código, mas o script JS está num outro diretório e não consegui visualizá-lo.
Valeu
Abraços
- BobbyCak likes this



Postagens
Não informado

