document.cadastra.reset();, ai na hora em que cadastrava, ou alterava, os campos do form apagavam.
ai desabilitei, colocando assim //document.cadastra.reset();, tem algum problema ?
outra coisa é que o listaClientes : function(campo, tipo){//OK, funciona de um jeito, assim, quando cadastro ou altero, a tabela que esta no div já é mostrada com a alteração ou com a inclusão, o restante como listaProjetos : function(campo, tipo), listaGrupos : function(campo, tipo) e listaNewsletter : function(campo, tipo), não funciona igual alguém poderia me explicar porque ?
pelo que eu entendi o div tem que ser este nome: document.getElementById('tabelaLista3'), document.getElementById('tabelaLista2') e document.getElementById('tabelaLista1'), sp que mesmo alterando ele não esta funcionando, ao cadastrar ou alterar tem que apertar o f5, para recarregar a pagina.
Pergunta
Guilherme014
try{ xmlhttp = new XMLHttpRequest(); }catch(ee){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(E){ xmlhttp = false; } } } campo = "cl_id"; tipo = "DESC"; pg = 0; var ajax = { camposForm : function(oForm){ var aParams = new Array(); for (var i=0; i < oForm.length; i++) { var sParam = oForm[i].id; sParam += "="; sParam += oForm[i].value; aParams.push(sParam); } return aParams.join("&"); }, repostasCadastro : function(){ mensagens = document.getElementById('msg'); if(xmlhttp.readyState == 1) mensagens.innerHTML = 'Aguarde Processando...'; if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200) { mensagens.innerHTML = xmlhttp.responseText; ajax.listaClientes(campo, tipo); //document.cadastra.reset(); } } }, listaClientes : function(campo, tipo){//OK ordena = campo; ordenar = tipo; local = document.getElementById('lista'); xmlhttp.open('GET', '../include/ajax.php?lista=1&campo='+ordena+'&tipo='+ordenar, true); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 1) { if(document.getElementById('tabelaLista')) anime.fade(document.getElementById('tabelaLista'), 100, 20, 500); } if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200){ local.innerHTML = xmlhttp.responseText; if(document.getElementById('tabelaLista')) anime.fade(document.getElementById('tabelaLista'), 20, 100, 500); } } } xmlhttp.send(null); }, listaProjetos : function(campo, tipo){//OK ordena = campo; ordenar = tipo; local = document.getElementById('lista2'); xmlhttp.open('GET', '../include/ajax.php?lista=2&campo='+ordena+'&tipo='+ordenar, true); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 1) { if(document.getElementById('tabelaLista1')) anime.fade(document.getElementById('tabelaLista1'), 100, 20, 500); } if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200){ local.innerHTML = xmlhttp.responseText; if(document.getElementById('tabelaLista1')) anime.fade(document.getElementById('tabelaLista1'), 20, 100, 500); } } } xmlhttp.send(null); }, listaGrupos : function(campo, tipo){//OK ordena = campo; ordenar = tipo; local = document.getElementById('lista3'); xmlhttp.open('GET', '../include/ajax.php?lista=3&campo='+ordena+'&tipo='+ordenar, true); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 1) { if(document.getElementById('tabelaLista2')) anime.fade(document.getElementById('tabelaLista2'), 100, 20, 500); } if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200){ local.innerHTML = xmlhttp.responseText; if(document.getElementById('tabelaLista2')) anime.fade(document.getElementById('tabelaLista2'), 20, 100, 500); } } } xmlhttp.send(null); }, listaNewsletter : function(campo, tipo){//OK ordena = campo; ordenar = tipo; local = document.getElementById('lista4'); xmlhttp.open('GET', '../include/ajax.php?lista=4&campo='+ordena+'&tipo='+ordenar, true); xmlhttp.onreadystatechange = function(){ if(xmlhttp.readyState == 1) { if(document.getElementById('tabelaLista3')) anime.fade(document.getElementById('tabelaLista3'), 100, 20, 500); } if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200){ local.innerHTML = xmlhttp.responseText; if(document.getElementById('tabelaLista3')) anime.fade(document.getElementById('tabelaLista3'), 20, 100, 500); } } } xmlhttp.send(null); }, EnviarNewsletter : function(id){//OK if(confirm("Tem certeza que deseja enviar esta newsletter ?")) { xmlhttp.open('GET', '../include/ajax.php?envia=1&id='+id, true); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(null); } }, deletaClientes : function(id){//OK if(confirm("Tem certeza que deseja excluir este cliente ?")) { xmlhttp.open('GET', '../include/ajax.php?deleta=1&id='+id, true); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(null); } }, deletaProjetos : function(id){//OK if(confirm("Tem certeza que deseja excluir este projeto ?")) { xmlhttp.open('GET', '../include/ajax.php?deleta=2&id='+id, true); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(null); } }, deletaGrupos : function(id){//OK if(confirm("Tem certeza que deseja excluir este grupo ?")) { xmlhttp.open('GET', '../include/ajax.php?deleta=3&id='+id, true); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(null); } }, deletaNewsletter : function(id){//OK if(confirm("Tem certeza que deseja excluir esta newsletter ?")) { xmlhttp.open('GET', '../include/ajax.php?deleta=4&id='+id, true); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(null); } }, editaClientes : function(id){ xmlhttp.open('GET', '../include/ajax.php?edita=1&id='+id, true); xmlhttp.onreadystatechange = ajax.edicaoTratamento; xmlhttp.send(null); }, editarProjetos : function(id){ xmlhttp.open('GET', '../include/ajax.php?edita=2&id='+id, true); xmlhttp.onreadystatechange = ajax.edicaoTratamento; xmlhttp.send(null); }, editarGrupos : function(id){ xmlhttp.open('GET', '../include/ajax.php?edita=3&id='+id, true); xmlhttp.onreadystatechange = ajax.edicaoTratamento; xmlhttp.send(null); }, editarNewsletter : function(id){ xmlhttp.open('GET', '../include/ajax.php?edita=4&id='+id, true); xmlhttp.onreadystatechange = ajax.edicaoTratamento; xmlhttp.send(null); }, confirmar : function(parametro){//OK if(confirm("Tem certeza que deseja gravar "+parametro+" ?")) {//OK if(parametro == "clientes"){//OK formulario = document.cadastra.elements; param = ajax.camposForm(formulario); xmlhttp.open('POST', '../include/ajax.php?cadastro=1', true); xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(param); } else if(parametro == "projeto"){//OK formulario = document.cadastra.elements; param = ajax.camposForm(formulario); xmlhttp.open('POST', '../include/ajax.php?cadastro=2', true); xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(param); } else if(parametro == "grupo"){//OK formulario = document.cadastra.elements; param = ajax.camposForm(formulario); xmlhttp.open('POST', '../include/ajax.php?cadastro=3', true); xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(param); } else if(parametro == "newsletter"){//OK formulario = document.cadastra.elements; param = ajax.camposForm(formulario); xmlhttp.open('POST', '../include/ajax.php?cadastro=4', true); xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xmlhttp.onreadystatechange = ajax.repostasCadastro; xmlhttp.send(param); } } } }o problema é na hora em que chega nesta parterepostasCadastro : function(){ mensagens = document.getElementById('msg'); if(xmlhttp.readyState == 1) mensagens.innerHTML = 'Aguarde Processando...'; if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200) { mensagens.innerHTML = xmlhttp.responseText; ajax.listaClientes(campo, tipo); //document.cadastra.reset(); } } },ele estava assim,repostasCadastro : function(){ mensagens = document.getElementById('msg'); if(xmlhttp.readyState == 1) mensagens.innerHTML = 'Aguarde Processando...'; if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200) { mensagens.innerHTML = xmlhttp.responseText; ajax.listaClientes(campo, tipo); document.cadastra.reset(); } } },document.cadastra.reset();, ai na hora em que cadastrava, ou alterava, os campos do form apagavam.
ai desabilitei, colocando assim //document.cadastra.reset();, tem algum problema ?
outra coisa é que o listaClientes : function(campo, tipo){//OK, funciona de um jeito, assim, quando cadastro ou altero, a tabela que esta no div já é mostrada com a alteração ou com a inclusão, o restante como listaProjetos : function(campo, tipo), listaGrupos : function(campo, tipo) e listaNewsletter : function(campo, tipo), não funciona igual alguém poderia me explicar porque ?
pelo que eu entendi o div tem que ser este nome: document.getElementById('tabelaLista3'), document.getElementById('tabelaLista2') e document.getElementById('tabelaLista1'), sp que mesmo alterando ele não esta funcionando, ao cadastrar ou alterar tem que apertar o f5, para recarregar a pagina.
se alguém não entendeu é so falar.
Link para o comentário
Compartilhar em outros sites
1 resposta a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.