Jump to content


Photo

Innerhtml + Html + Ie


  • Faça o login para participar
Nenhuma resposta neste tópico

#1 gmps

gmps

    Amsdã

  • Usuários
  • 969 posts
  • Sexo:Não informado

Posted 17/11/2010, 07:06

galera, eu tenho um form para solicitacao de livro, a pessoa pode solicitar 1 ou mais livros, eu quero que quando a pessoa clicar no botao para incluir mais livros, um novo form é adicionado....o codigo abaixo funciona no firefox e no chrome, mas no IE nao pq sera?


<html>

<head>
<title>BIBLIOTECA</title>
<link rel="stylesheet" href="images/estilo1.css" type="text/css">
<script language="JavaScript">
var qtdeCampos = 1;

function addCampos()
{
	var objPai = document.getElementById("campoPai");
	//Criando o elemento DIV;
	var objFilho = document.createElement("div");
	//Definindo atributos ao objFilho:
	objFilho.setAttribute("id","filho"+qtdeCampos);

	//Inserindo o elemento no pai:
	objPai.appendChild(objFilho);

	//Escrevendo algo no filho recém-criado:
	document.getElementById("filho"+qtdeCampos).innerHTML = "<tr><td class='texto' align='left'><table width='100%' align='left' border='1'><tr><td class='texto' width='20%' align='left'>Tipo Livro:</td><td class='form' width='80%' align='left'> <select id='TIPO_LIVRO"+qtdeCampos+"' name='TIPO_LIVRO[]' size='1' class='edit' ><option>Escolha aqui...</option><option value='CIENTÍFICO'>Científico</option><option value='DIDÁTICO'>Didático</option></select></td></tr><tr> <td class='texto' width='20%' align='left'>ISBN:</td><td class='form' width='80%' align='left'><input type='text' id='ISBN"+qtdeCampos+"' name='ISBN[]' size='20' class='edit' VALUE=''></td></tr><tr> <td class='texto' width='20%' align='left'><font color='#FF0000'><b>*</b></font>Autor(es): </td><td class='form' width='80%' align='left'> <textarea rows='5' id='AUTOR"+qtdeCampos+"' name='AUTOR[]' cols='55' class='edit' value=''></textarea></td></tr><tr> <td class='texto' width='20%' align='left'><font color='#FF0000'><b>*</b></font>T&iacute;tulo:</td><td align='left' class='form' width='80%' align='left'> <input type='text' id='TITULO"+qtdeCampos+"' name='TITULO[]' size='55' class='edit' value=''></td></tr><tr> <td class='texto' width='20%' align='left'>Idioma:</td><td class='form' width='80%' align='left'><input type='text' id='IDIOMA"+qtdeCampos+"' name='IDIOMA[]' size='55' class='edit' value=''></td></tr><tr> <td class='texto' width='20%' align='left'><font color='#FF0000'><b>*</b></font>Editora:</td><td class='form' width='80%' align='left'><input type='text' id='EDITORA"+qtdeCampos+"' name='EDITORA[]' size='55' class='edit' value=''></td></tr><tr> <td class='texto' width='20%' align='left'>Ano:</td><td class='form' width='80%' align='left'><input type='text' id='ANO"+qtdeCampos+"' name='ANO[]' size='6' class='edit' value=''>&nbsp;&nbsp;&nbsp;&nbsp;Edi&ccedil;&atilde;o: &nbsp;<input type='text' id='EDICAO"+qtdeCampos+"' name='EDICAO[]'size='6' class='edit' value=''>&nbsp;&nbsp;&nbsp;&nbsp;Volumes: &nbsp;<input type='text' id='VOLUMES"+qtdeCampos+"' name='VOLUMES[]' size='6' class='edit' value=''></td></tr><tr> <td class='texto' width='20%' align='left'><font color='#FF0000'><b>*</b></font> Exemplares:</td><td class='form' width='80%' align='left'><input type='text' id='EXEMPLARES"+qtdeCampos+"' name='EXEMPLARES[]' size='6' class='edit'>&nbsp;&nbsp;&nbsp;&nbsp;Moeda: &nbsp;<select name='MOEDA' size='1' class='edit'><option value='R$'>R$</option><option value='US$'>US$</option></select>&nbsp;&nbsp;&nbsp;&nbsp;Pre&ccedil;o Unit.: &nbsp;<input type='text' id='PRECO_UNIT"+qtdeCampos+"' name='PRECO_UNIT[]' size='8' class='edit' value=''></td></tr><tr > <td class='texto' width='20%' align='left'><font color='#FF0000'><b>*</b></font>Prioridade:</td><td class='form' width='80%' align='left'> <select id='PRIORIDADE"+qtdeCampos+"' name='PRIORIDADE[]' size='1' class='edit'><option value='IMPORTANTE'>Importante</option><option value='IMPRESCINDIVEL'>Imprescindível</option></select></td></tr><tr> <td class='texto' width='20%' align='left'>Observa&ccedil;&otilde;es:</td><td class='form' width='80%' align='left'><textarea rows='5' id='OBSERVACOES"+qtdeCampos+"' name='OBSERVACOES[]' cols='55' class='edit' value=''></textarea></td></tr></table></td></tr>";

	//document.getElementById("filho"+qtdeCampos).innerHTML = "bla<br>";

	qtdeCampos++;
}

function removerCampo(id)
{
	var objPai = document.getElementById("campoPai");
	var objFilho = document.getElementById("filho"+id);

	//Removendo o DIV com id específico do nó-pai:
	var removido = objPai.removeChild(objFilho);
}
</script>
</head>
<body>
<center><img src="images/titulo.gif" ></center>
<form method="POST" action="pedlivroTESTE.php" name="pedlivro" > 
<table width="100%">
	<tr>
		<td>
			<table border="0" width="100%" class="fontes" bgcolor='#EEEEEE'>
				<tr> 
					<td class='azulescuro' bgcolor="#333399" align="left"><font face="Verdana"><font color="#FFFFFF"><b><font size="3">*</font></b></font><b><font color="#FFFFFF"> - Preenchimento Obrigatório </font></b></font></td>
				</tr>
				<tr> 
					<td align="left" class="textomaior"> - DADOS DO SOLICITANTE -</td>
				</tr>
				<tr> 
					<td class="texto" align="left">
						<table width="100%" align="left" border="1">
							<tr class="texto">
								<td class="texto" width="20%" align="left"><b><font color="#FF0000">*</font></b> Nome:</td>
								<td class="form" width="80%" align="left"><input type="text" name="NOME" size="55" class="edit" value="<?echo $NOME;?>"></td>
							</tr>
							<tr class="texto"> 
								<td class="texto" width="20%" align="left"><font color="#FF0000"><b>*</b></font>E-mail:</td>
								<td class="form" width="80%" align="left"><input type="text" name="EMAIL" size="55" class="edit" value="<?echo $EMAIL;?>"></td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left"><b><font color="#FF0000">*</font></b> Depto:</td>
								<td class="form" width="80%" align="left"> 
									<select name="DEPARTAMENTO" size="1" class="edit">
									  <option value="-">Escolha aqui...</option>
									  <option value="ADM">Administrativo</option>
									  <option value="DASE">Administração e Supervisão Escolar</option>
									  <option value="DCI">Ciência da Informação</option>
									  <option value="DCPE">Ciências Políticas e Econômicas</option>
									  <option value="DDID">Didática</option>
									  <option value="DEE">Educação Especial</option>
									  <option value="DFIL">Filosofia</option>
									  <option value="DFONO">Fonoaudiologia</option>
									  <option value="DPE">Psicologia da Educação</option>
									  <option value="DSA">Sociologia e Antropologia</option>
									</select>
								</td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left"><b><font color="#FF0000">*</font></b> Disciplina(s):</td>
								<td class="form" width="80%" align="left"> <textarea rows="5" name="DISCIPLINA" cols="55" class="edit"></textarea></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td class="textomaior" align="left"> - DADOS DO LIVRO - </td>
				</tr>
				<tr> 
					<td class="texto" align="left">
						<table width="100%" align="left" border="1">	
							<tr> 
								<td class="texto" width="20%" align="left">Tipo Livro:</td>
								<td class="form" width="80%" align="left"> 
									<select id="TIPO_LIVRO0" name="TIPO_LIVRO[]" size="1" class="edit" >
									  <option>Escolha aqui...</option>
									  <option value="CIENTÍFICO">Científico</option>
									  <option value="DIDÁTICO">Didático</option>
									</select>
								</td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left">ISBN:</td>
								<td class="form" width="80%" align="left"><input type="text" id="ISBN0" name="ISBN[]" size="20" class="edit" VALUE=''></td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left"><font color="#FF0000"><b>*</b></font>Autor(es): </td>
								<td class="form" width="80%" align="left"> <textarea rows="5" id="AUTOR0" name="AUTOR[]" cols="55" class="edit" value=''></textarea></td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left"><font color="#FF0000"><b>*</b></font>T&iacute;tulo:</td>
								<td align="left" class="form" width="80%" align="left"> <input type="text" id="TITULO0" name="TITULO[]" size="55" class="edit" value=''></td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left">Idioma:</td>
								<td class="form" width="80%" align="left"><input type="text" id="IDIOMA0" name="IDIOMA[]" size="55" class="edit" value=''></td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left"><font color="#FF0000"><b>*</b></font>Editora:</td>
								<td class="form" width="80%" align="left"><input type="text" id="EDITORA0" name="EDITORA[]" size="55" class="edit" value=''></td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left">Ano:</td>
								<td class="form" width="80%" align="left">
									<input type="text" id="ANO0" name="ANO[]" size="6" class="edit" value=''>&nbsp;&nbsp;&nbsp;&nbsp;Edi&ccedil;&atilde;o: &nbsp;<input type="text" id="EDICAO0" name="EDICAO[]"size="6" class="edit" value=''>
									&nbsp;&nbsp;&nbsp;&nbsp;Volumes: &nbsp;<input type="text" id="VOLUMES0" name="VOLUMES[]" size="6" class="edit" value=''>
								</td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left"><font color="#FF0000"><b>*</b></font> Exemplares:</td>
								<td class="form" width="80%" align="left"><input type="text" id="EXEMPLARES0" name="EXEMPLARES[]" size="6" class="edit">&nbsp;&nbsp;&nbsp;&nbsp;
								Moeda: &nbsp;
								<select name="MOEDA" size="1" class="edit">
								  <option value="R$">R$</option>
								  <option value="US$">US$</option>
								</select>&nbsp;&nbsp;&nbsp;&nbsp;
								Pre&ccedil;o Unit.: &nbsp;<input type="text" id="PRECO_UNIT0" name="PRECO_UNIT[]" size="8" class="edit" value=''>
								</td>
							</tr>
							<tr > 
								<td class="texto" width="20%" align="left"><font color="#FF0000"><b>*</b></font>Prioridade:</td>
								<td class="form" width="80%" align="left"> 
								<select id="PRIORIDADE0" name="PRIORIDADE[]" size="1" class="edit">
								  <option value="IMPORTANTE">Importante</option>
								  <option value="IMPRESCINDIVEL">Imprescindível</option>
								</select>
								</td>
							</tr>
							<tr> 
								<td class="texto" width="20%" align="left">Observa&ccedil;&otilde;es:</td>
								<td class="form" width="80%" align="left"><textarea rows="5" id="OBSERVACOES0" name="OBSERVACOES[]" cols="55" class="edit" value=''></textarea></td>
							</tr>
						</table>						
					</td>
				</tr>
				<div id="campoPai"></div>						
				<tr> 
					<td align="center">&nbsp;</td>
				</tr>
				<tr> 
					<td align="center"><input type="button" class="edit" value="Adicionar Outro Livro" onclick="addCampos()"></td>
				</tr>
				<tr > 
					<td><hr align="center"></td>
				</tr>
				<tr> 
					<td class="texto2"><input type="submit" name="Enviar"  value="Enviar" class="edit">&nbsp;&nbsp;<input type="reset" name="Limpar" value="Limpar" class="edit"></td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</form>
</body>
</html>


se eu fizer somente
document.getElementById("filho"+qtdeCampos).innerHTML = "bla<br>";

da certo no IE, mas com html nao
"Se você não puder ajudar, atrapalhe; afinal, o importante é participar..."




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq