Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

kessiag

Duas funções no mesmo botão

Recommended Posts

Boa tarde pessoal. http://forum.imasters.com.br/public/style_emoticons/default/grin.gif

 

 

Eu faço protótipos de tela em html e javascript e preciso tirar uma dúvida.

Tenho um formulário com 3 campos input e 2 botoes: NOVO E GRAVAR.

 

1) O botão NOVO deve inserir uma nova linha ao formulário

2) O botão gravar deve exibir a mensagem: REGISTRO GRAVADO COM SUCESSO na parte superior da tela (a mensagem contém imagens)

3) Ao clicar no botão novo novamente, ele deve inserir outra linha e ao mesmo tempo apagar a mensagem de confirmação.

 

As tarefas 1 e 2 já estão concluídas porém nao sei como fazer a 3!

Acredito que ele o botão novo deve precisar de duas funções, uma para a criação da nova linha e outra para a exclusão do objeto inserido dinamicamente.

 

Segue abaixo os scripts dos dois botões.

Aguardo respostas... http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif Obrigada.

 

<script LANGUAGE="JavaScript">  
	function addRow(id){  
	var tbody = document.getElementById  
	(id).getElementsByTagName("TBODY")[0];  
	
	//cria a linha da tabela
	var row = document.createElement("TR");
	row.setAttribute("height", "50");	
	
	//cria a primeiro td  
	var td1 = document.createElement("TD")  

	var currentElement = document.createElement("input");  
	currentElement.setAttribute("type", "text");  
	currentElement.setAttribute("name", "oInput" + id);  
	currentElement.setAttribute("id", "oInput" + id);
	currentElement.setAttribute("size", "oInput" + "6");

	td1.appendChild(currentElement); 
		 
	//cria o segundo td  
	var td2 = document.createElement("TD")  
   
	var currentElement = document.createElement("input");  
	currentElement.setAttribute("type", "text");  
	currentElement.setAttribute("name", "oInput" + id);  
	currentElement.setAttribute("id", "oInput" + id);
	currentElement.setAttribute("size", "oInput" + "50");

	td2.appendChild(currentElement);
	 
	var currentElement = document.createElement("input");  
	currentElement.setAttribute("type", "image");  
	currentElement.setAttribute("name", "obrig" + id);  
	currentElement.setAttribute("src", "Midia/ico_obrig.gif");

	td2.appendChild(currentElement);   

	//cria o terceiro td  
	var td3 = document.createElement("TD")  
   
	var currentElement = document.createElement("input");  
	currentElement.setAttribute("type", "text");  
	currentElement.setAttribute("name", "oInput" + id);  
	currentElement.setAttribute("id", "oInput" + id);
	currentElement.setAttribute("size", "oInput" + "3");

	td3.appendChild(currentElement); 
	 
	var currentElement = document.createElement("input");  
	currentElement.setAttribute("type", "image");  
	currentElement.setAttribute("name", "obrig" + id);  
	currentElement.setAttribute("src", "Midia/ico_obrig.gif");

	td3.appendChild(currentElement); 
   
	//cria o quarto td  
	var td4 = document.createElement("TD")  
   
	var currentElement = document.createElement("input");  
	currentElement.setAttribute("type", "text");  
	currentElement.setAttribute("name", "oInput" + id);  
	currentElement.setAttribute("id", "oInput" + id);
	currentElement.setAttribute("size", "oInput" + "7");

	td4.appendChild(currentElement); 
	 
	var currentElement = document.createElement("input");  
	currentElement.setAttribute("type", "image");  
	currentElement.setAttribute("name", "obrig" + id);  
	currentElement.setAttribute("src", "Midia/ico_obrig.gif");

	td4.appendChild(currentElement);
	 
	row.appendChild(td1);  
	row.appendChild(td2);  
	row.appendChild(td3); 
	row.appendChild(td4); 
	tbody.appendChild(row);
	tbody.appendChild(linha2);	
	}  
   
</script>




<script>
	function confirma(id){
	<!-- TABELA CONFIRMAÇÃO -->
	
	var tabela = document.getElementById('gravar').innerHTML = "<div style='position:absolute; left:5px; top:0px; width:90%; height:50; z-index:1;'><div style='position:absolute; left:0px; top:0px; width:150px; height:66;z-index:1;'><img src='Midia/msgAzul/ico.gif' /></div><div style='position:absolute; left:-18px; top:2px; width:1440px; height:100; z-index:1;'><div style=''><table border = '0' width='96%'  cellspacing='0' cellpadding='0' align='right'><tr><td width='7' height='3' background='Midia/msgAzul/supesq.gif'/></td><td height='7' background='Midia/msgAzul/sup.gif'/></td><td width='7' height='3' background='Midia/msgAzul/supdir.gif'/></td></tr><tr><td width='7' background='Midia/msgAzul/esq.gif'></td><td bgcolor='#DFEAEC' style='background-image:'Midia/msgAzul/lin.gif'; background-repeat: no-repeat;'><img align='absmiddle' height='11' hspace='4' src='Midia/msgAzul/lin.gif' vspace='4' width='11'><style1>Registro gravado com sucesso</style1></td><td width='7' background='Midia/msgAzul/dir.gif'></td></tr><tr><td width='7' height='3' background='Midia/msgAzul/infesq.gif'/><td height='7' background='Midia/msgAzul/inf.gif'/><td width='7' height='3' background='Midia/msgAzul/infdir.gif'/></table></div></div>";
	
}


</script>
editado por Otata 06/07/2009 14:05

Compartilhar este post


Link para o post
Compartilhar em outros sites

Que tal fazer como que a mensagem suma automaticamente depois de algum tempo??? http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif

 

Use a função setTimeout...

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.