ncs_nayara 4 de out. de 2007
Ninguém?
Alguém já fez algo parecido … se alguém tiver outra idéia …
Estou aberta a opniões …
Muito obrigada!
guilherme737 4 de out. de 2007
Geralmente eu monto minhas tabelas dinamicas assim... e uso campos hidden para setar valores nas variaveis correspondentes no meu ActionForm...
function adicionarProdutos () {
if ( document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value == "" ){
document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . focus ();
alert ( '<bean:message key="estoque.transferenciaEstoque.alert.produto" />' );
return false ;
} else if ( document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value == "0" ||
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value == "" ){
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . focus ();
alert ( '<bean:message key="estoque.transferenciaEstoque.alert.quantidade" />' );
return false ;
}
if ( ! document . all ) {
document . getElementById ( "TR_PRODUTOS" ) . style . display = "table-row" ;
} else {
document . getElementById ( "TR_PRODUTOS" ) . style . display = "block" ;
}
var tabela = document . getElementById ( "produtos" );
var row = tabela . insertRow ( 1 );
row . id = "trProd" + num ++ ;
var i = 0 ;
var cel = row . insertCell ( i ++ );
cel . id = row . id + "Col" + i ;
cel . innerHTML = document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value ;
var cel = row . insertCell ( i ++ );
cel . id = row . id + "Col" + i ;
cel . innerHTML = document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value ;
var cel = row . insertCell ( i ++ );
cel . id = row . id + "Col" + i ;
cel . innerHTML = ""
+ "<input type='hidden' name='produto' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.produto.codigo' ] . value + "'>"
+ "<input type='hidden' name='produtoNome' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value + "'>"
+ "<input type='hidden' name='produtoQuantidade' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.quantidade' ] . value + "'>"
+ "<input type='hidden' name='produtoQuantidadeAux' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value + "'>"
+ "<a href='#' onClick= \" alterarProdutos('" + row . id + "');return false; \" ><img src='../images/botoes/editar.gif' border='0'></a>"
+ " "
+ "<a href='#' onClick= \" removerProdutos('" + row . id + "');return false; \" ><img src='../images/botoes/resolver.gif' border='0'></a>" ;
document . transferenciaEstoqueForm [ 'codigoBarra' ] . value = "" ;
document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value = "" ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidade' ] . value = "0" ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value = "0,00" ;
document . transferenciaEstoqueForm [ 'codigoBarra' ] . focus ();
}
function alterarProdutos ( linha ){
var cel = document . getElementById ( linha );
var inputs = cel . getElementsByTagName ( 'input' );
var i = 0 ;
document . transferenciaEstoqueForm [ 'vo.estoque.produto.codigo' ] . value = inputs [ i ++ ] . value ;
document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value = inputs [ i ++ ] . value ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidade' ] . value = inputs [ i ++ ] . value ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value = inputs [ i ++ ] . value ;
var bt = document . getElementById ( "addProd" );
bt . value = "Salvar" ;
bt . onclick = function onclick ( event ){ salvarProdutos ( linha );};
}
function salvarProdutos ( linha ){
if ( document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value == "" ){
document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . focus ();
return false ;
} else if ( document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value == "0" ||
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value == "" ){
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . focus ();
return false ;
}
var row = document . getElementById ( linha );
var i = 0 ;
i ++
var cel = document . getElementById ( linha + "Col" + i );
cel . innerHTML = document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value ;
i ++
var cel = document . getElementById ( linha + "Col" + i );
cel . innerHTML = document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value ;
i ++
var cel = document . getElementById ( linha + "Col" + i );
cel . innerHTML = ""
+ "<input type='hidden' name='produto' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.produto.codigo' ] . value + "'>"
+ "<input type='hidden' name='produtoNome' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value + "'>"
+ "<input type='hidden' name='produtoQuantidade' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.quantidade' ] . value + "'>"
+ "<input type='hidden' name='produtoQuantidadeAux' value='" + document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value + "'>"
+ "<a href='#' onClick= \" alterarProdutos('" + row . id + "');return false; \" ><img src='../images/botoes/editar.gif' border='0'></a>"
+ " "
+ "<a href='#' onClick= \" removerProdutos('" + row . id + "');return false; \" ><img src='../images/botoes/resolver.gif' border='0'></a>" ;
document . transferenciaEstoqueForm [ 'codigoBarra' ] . value = "" ;
document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value = "" ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidade' ] . value = "0" ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value = "0" ;
var bt = document . getElementById ( "addProd" );
bt . value = "Adicionar" ;
bt . onclick = function onclick ( event ){ adicionarProduto ();};
}
function removerProdutos ( linha ){
var aux = document . getElementById ( linha );
var tabela = document . getElementById ( "produtos" );
var inputs = aux . getElementsByTagName ( 'input' );
var i = 2 ;
tabela . deleteRow ( aux . rowIndex );
document . transferenciaEstoqueForm [ 'codigoBarra' ] . value = "" ;
document . transferenciaEstoqueForm [ 'vo.estoque.produto.nome' ] . value = "" ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidade' ] . value = "0" ;
document . transferenciaEstoqueForm [ 'vo.estoque.quantidadeAux' ] . value = "0" ;
var bt = document . getElementById ( "addProd" );
bt . value = "Adicionar" ;
bt . onclick = function onclick ( event ){ adicionarProduto ();};
if ( tabela . rows . length < 2 ){
document . getElementById ( "TR_PRODUTOS" ) . style . display = "none" ;
}
}