estou tendo problemas com um sistema de pedidos on-line identico a este: http://www.metalnox....suprimentos.php
inclusive estou usando o mesmo código, pois trata-se do mesmo site "com cara nova" a nova versão está em http://www.metalnox..../orcamentos.php
O caso é que no novo site, a parte onde deveria atualizar com os produtos no carrinho, não está carregando a lista de produtos
segue abaixo o codigo no cabeçalho da pagina de pedidos:
<?php require_once('Connections/conectabd.php'); require_once("required.php");?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:wdg="http://ns.adobe.com/addt"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><script type="text/javascript" src="js/lib/tw-sack.js"></script><script type="text/javascript" src="js/site.js"></script><script type="text/javascript">function Orcamentos() { this.carregar = function() { orcamentos.tabela_mensagem('ATUALIZANDO'); ajax1 = new sack('orcamentos_suprimentos_adicionar.php'); ajax1.onCompletion = orcamentos.carregar_exibir; ajax1.method = "POST"; ajax1.setVar('carregar',1); ajax1.runAJAX(); } this.adicionar = function(id,quantidade) { ajax2 = new sack('orcamentos_suprimentos_adicionar.php'); ajax2.method = "POST"; ajax2.onCompletion = orcamentos.carregar; ajax2.setVar('id',$('produtos_select').value); ajax2.setVar('quantidade',$('edtQuantidade').value); ajax2.runAJAX(); } this.remover = function(id) { ajax3 = new sack('orcamentos_suprimentos_adicionar.php'); ajax3.method = "POST"; ajax3.onCompletion = orcamentos.carregar; ajax3.setVar('remover',id); ajax3.runAJAX(); } this.limpar = function() { ajax3 = new sack('orcamentos_suprimentos_adicionar.php'); ajax3.method = "POST"; ajax3.setVar('limpar',1); ajax3.runAJAX(); } this.carregar_exibir = function() { obj = ajax1.responseXML; campos = obj.getElementsByTagName('produto'); if (campos.length == 0) { orcamentos.tabela_mensagem('NENHUM PRODUTO NO CARRINHO.'); return; } orcamentos.tabela_limpar(); for (var i=0;i<campos.length;i++) { var id = campos[i].getElementsByTagName('id')[0].firstChild.nodeValue; var nome = campos[i].getElementsByTagName('nome')[0].firstChild.nodeValue; var quantidade = campos[i].getElementsByTagName('quantidade')[0].firstChild.nodeValue; var linha = $('PRODUTOS_LISTA').insertRow(0); linha.insertCell(0); linha.insertCell(1); linha.insertCell(2); linha.childNodes[0].className = 'quantidade'; linha.childNodes[0].innerHTML = quantidade; linha.childNodes[1].className = 'nome'; linha.childNodes[1].innerHTML = nome; linha.childNodes[2].className = 'remover'; linha.childNodes[2].innerHTML = '<a href="java script:void(0)" onclick="orcamentos.remover(' + id + ')"><img src="imagens/orcamentos/remover.gif" /></a>'; } } this.tabela_limpar = function() { while ($('PRODUTOS_LISTA').rows.length != 0) { $('PRODUTOS_LISTA').deleteRow(0); } } this.tabela_mensagem = function(mensagem) { orcamentos.tabela_limpar(); linha = $('PRODUTOS_LISTA').insertRow(0); linha.insertCell(0); linha.childNodes[0].id = 'carregando'; linha.childNodes[0].innerHTML = mensagem; }}orcamentos = new Orcamentos;adicionarEvento(window,'load',orcamentos.carregar);function Produtos() { this.produtos = function(id) { if (id == 0) return; ajax1 = new sack('suprimentos-xml.php'); ajax1.onCompletion = produtos.produtos_exibir; ajax1.method = "POST"; ajax1.setVar('produtos',id); ajax1.runAJAX(); } this.produtos_exibir = function() { if (!ajax1.responseXML) return; obj = ajax1.responseXML; campos = obj.getElementsByTagName('produto'); $('produtos_select').length = 1; for (var i=0;i<campos.length;i++) { var id = campos[i].getElementsByTagName('id')[0].firstChild.nodeValue; var nome = campos[i].getElementsByTagName('nome')[0].firstChild.nodeValue; option = document.createElement('option'); option.setAttribute('value',id); option.innerHTML = nome; $('produtos_select').appendChild(option); } }}produtos = new Produtos;</script>
e na parte onde deveria aparecer o conteúdo do carrinho:
<div id="mainAcessoriosProdutos"><table width="416" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="220" valign="top"><form id="formFornecedores" name="formFornecedores" method="post" action="" onsubmit="return false;"> Categorias:<br /> <select name="categorias" class="tamanho1" id="categorias" onchange="produtos.produtos(this.value)"> <option value="0">Selecione</option><?php$sql = 'SELECT * ' . 'FROM `suprimentos_categorias` ' . 'ORDER BY `nome` ASC';$sql = mysql_query($sql);while ($i = mysql_fetch_array($sql)) {?> <option value="<?php print $i['id']; ?>"><?php print $i['nome']; ?></option><?php}?> </select> <br /> Produtos:<br /> <select name="produtos_select" class="tamanho1" id="produtos_select"> <option value="0">Selecione</option> </select> <div id="produtos_quantidade"> Quantidade:<br /> <input name="edtQuantidade" type="text" class="tamanho1" id="edtQuantidade" /> <br /> <input type="submit" value="Adicionar" onclick="orcamentos.adicionar();" /> </div> </form> </td> <td width="196" valign="top"><table width="197" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="34" background="imagens/orcamentos/lista-topo.gif" style="padding-left:10px"><span style="font:Impact, Helvetica, sans-serif; font-size:14px; color:#FFFFFF; font-weight:bold;">ORÇAMENTO</span></td> </tr> <tr> <td background="imagens/orcamentos/lista-fundo.gif"> <table id="PRODUTOS_LISTA" width="195" border="0" cellspacing="0" cellpadding="0"> </table> </td> </tr> <tr> <td height="50" valign="bottom" background="imagens/orcamentos/lista-fundo.gif"><a href="orcamentos-suprimentos-enviar.php"><img src="imagens/orcamentos/lista-base.gif" width="197" height="40" border="0" /></a></td> </tr> </table></td> </tr> </table> </div>
arquivo orçamentos_supromentos_adicionar.php:
<?phprequire_once("required.php");if (sizeof($_SESSION['suprimentos']) == 0) { $_SESSION['suprimentos'] = array();}$_POST['id'] = (int) $_POST['id'];if ($_POST['id']) { $_POST['quantidade'] == (int) $_POST['quantidade']; if ($_POST['quantidade'] == 0) { unset($_SESSION['suprimentos'][$_POST['id']]); } else { $_SESSION['suprimentos'][$_POST['id']] = array($_POST['id'],$_POST['quantidade']); }}if ($_POST['carregar']) { $xml .= '<?xml version="1.0" encoding="iso-8859-1"?>' . "\r\n"; $xml .= '<produtos>' . "\r\n"; foreach ($_SESSION['suprimentos'] as $produto) { $sql = 'SELECT * ' . 'FROM `suprimentos` ' . 'WHERE `id` = \'' . $produto[0] . '\' ' . 'LIMIT 1'; $sql = mysql_query($sql); $num = mysql_num_rows($sql); if ($num == 0) { unset($_SESSION['suprimentos'][$produto[0]]); } else { $produto_sql = mysql_fetch_assoc($sql); $xml .= ' <produto>' . "\r\n"; $xml .= ' <id>' . $produto[0] . '</id>' . "\r\n"; $xml .= ' <nome>' . $produto_sql['nome'] . '</nome>'; $xml .= ' <quantidade>' . $produto[1] . '</quantidade>' . "\r\n"; $xml .= ' </produto>' . "\r\n"; } } $xml .= '</produtos>' . "\r\n"; header('Content-type: application/xml; charset=iso-8859-1'); print $xml;}$_POST['remover'] = (int) $_POST['remover'];if ($_POST['remover']) { unset($_SESSION['suprimentos'][$_POST['remover']]);}if ($_POST['limpar']) { unset($_SESSION['suprimentos']);}?>
Além disso, no diretorio do novo site, temos os mesmos arquivos AJAX.
Se alguém poder me dar uma pista do problema ficaria muito agradecido.
Edição feita por: Valderes Zimmer, 15/10/2009, 11:11.