Bom Dia a todos Bem eu to montando um sistema de venda de produtos aí chega a hora de escolher um produto e add ele eu queria fazer assim o cara seleciona um produto traz todas as infos do produto e quando ele clicar em "add ao carrinho" já mostra na mesma pagina na parte de produtos no carrinho como posso fazer isso? pagina dos produtos <?
include"../func/autentica.php";
require("../func/conn.php");
$qr_admin=mysql_query("select nivel from tbadmin where login = '".$_SESSION['usuario']."'");
$campoadmin=mysql_result($qr_admin,0,"nivel");
$sel_cliente="SELECT * from tbadmin WHERE login = '".$_SESSION['usuario']."'";
$qr_cliente=mysql_query($sel_cliente);
/*PEGA OS ESTADOS
$sql = "SELECT id, estado, prefixo FROM estados ORDER BY estado";
//EXECUTA A QUERY
$sql = mysql_query($sql);
$row = mysql_num_rows($sql);*/
$faz_orcamento = "SELECT *From tbclientes as ORDER BY txtNome ASC ";
$qr_orcamento=mysql_query($faz_orcamento);
$vendedor=mysql_query("select txtStatus from tbadmin where login = '".$_SESSION['usuario']."'");
$txtStatus=mysql_result($vendedor,0,"txtStatus");
?>
<html>
<head>
<link href="../estilos.css" rel="stylesheet" type="text/css" />
</head>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript">
function pesquisar_dados( valor )
{
http.open("GET", "consultar.php?IdClientes=" + valor, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function handleHttpResponse(){
campo_text = document.forms[0].subcategoria;
partes = http.responseText.split("|");
//partes[0] == txtEnd
//partes[1] == txtEstato
//partes[2] == txtCep
//partes[3] == txtCidade
//partes[4] == txtCpf
//partes[5] == txtRg
//partes[6] == txtBairro
//partes[7] == txtFone
//partes[8] == txtFax
//partes[9] == txtCelular
//partes[10] == txtEmail
//partes[11] == txtFone
if (http.readyState == 4) {
document.getElementById("txtEnd").innerHTML = partes[0];
document.getElementById("txtEstado").innerHTML = partes[1];
document.getElementById("txtCep").innerHTML = partes[2];
document.getElementById("txtCidade").innerHTML = partes[3];
document.getElementById("txtCpf").innerHTML = partes[4];
document.getElementById("txtRg").innerHTML = partes[5];
document.getElementById("txtBairro").innerHTML = partes[6];
document.getElementById("txtFone").innerHTML = partes[7];
document.getElementById("txtFax").innerHTML = partes[8];
document.getElementById("txtCelular").innerHTML = partes[9];
document.getElementById("txtEmail").innerHTML = partes[10];
}
}
function pesquisar_dado( valor )
{
http2.open("GET", "consultarProdutos.php?IdProd=" + valor, true);
http2.onreadystatechange = handleHttpResponse2;
http2.send(null);
}
function handleHttpResponse2(){
campo_text = document.forms[0].subcategoria;
teste = http2.responseText.split("|");
//teste[0] == CodProd
//teste[1] == NomeProd
//teste[2] == txtLP
//teste[3] == txtTamanho
//teste[4] == txtPreco
if (http2.readyState == 4) {
document.getElementById("CodProd").innerHTML = teste[0];
document.getElementById("NomeProd").innerHTML = teste[1];
document.getElementById("txtLP").innerHTML = teste[2];
document.getElementById("txtTamanho").innerHTML = teste[3];
document.getElementById("txtPreco").innerHTML = teste[4];
}
}
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != '') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject();
var http2 = getHTTPObject();
</script>
<title></title>
<meta http-equiv="Content-Type" content="text/html/application/xml; charset=iso-8859-1" />
<!--Fireworks 8 Dreamweaver 8 target. Created Mon May 15 16:58:37 GMT-0300 (Hora oficial do Brasil) 2006-->
</head>
<body bgcolor="#2c3e54">
<table width="778" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<!-- fwtable fwsrc="Untitled" fwbase="index.jpg" fwstyle="Dreamweaver" fwdocid = "1360913769" fwnested="0" -->
<tr>
<td width="224" rowspan="2" valign="top"><? if ($campoadmin=="2") {
include("../func/menu2.php");
}else {
include("../func/menu.php"); }
?></td>
<td width="6" rowspan="2" bgcolor="#D8C69E"><img src="../images/index_r1_c14.jpg" width="6" height="14" /></td>
<td width="544" height="16" valign="top" bgcolor="#F9F4EE"><img src="../images/btnCadCliente.jpg" width="549" height="181" /></td>
</tr>
<tr>
<td valign="top" bgcolor="#F9F4EE"><form action="fazOrcamento.php" method="post" name="cadastro">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="4" valign="top" bgcolor="#EFE2D3" class="tahoma11"><strong> Dados do Cliente : </strong></td>
</tr>
<tr>
<td width="15%" align="right" class="tahoma11">*Nome:</td>
<td>
<select name="txtNome" onChange="pesquisar_dados( this.value )">
<option></option>
<?php
$consulta = mysql_query("SELECT * FROM tbclientes ORDER BY txtNome ASC");
while( $row = mysql_fetch_assoc($consulta) )
{
echo "<option value=\"{$row['IdClientes']}\">{$row['txtNome']}</option>\n";
}
?>
</select></td><td align="right" class="tahoma11">Ordem:</td>
<td class="tahoma11"> <strong>
<?
$faz_ordem = mysql_query("SELECT IdOrcamento FROM tborcamento ORDER BY IdOrcamento DESC");
$row = mysql_fetch_array($faz_ordem);
$numOS = ( mysql_num_rows($faz_ordem) == 0 ) ? 1 : $row['IdOrcamento']+1;
?>
<? $cod = "$numOS"; echo sprintf("%04d",$cod);?></strong></td>
</tr>
<tr>
<td height="71" align="right" valign="top" bgcolor="#EFE2D3" class="tahoma11"><table width="100%" height="100" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20" align="right" class="tahoma11">Endereço:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">Cep:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">CPF:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">Bairro:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">Fax:</td>
</tr>
</table></td>
<td width="36%" valign="top" bgcolor="#EFE2D3"><table width="100%" height="100" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtEnd"></div></td>
</tr>
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtCep"></div></td>
</tr>
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtCpf"></div></td>
</tr>
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtBairro"></div></td>
</tr>
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtFax"></div></td>
</tr>
</table></td>
<td width="8%" align="right" valign="top" bgcolor="#EFE2D3"><table width="100%" height="80" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20" align="right" class="tahoma11">Estado:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">Cidade:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">RG:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">Fone:</td>
</tr>
</table></td>
<td width="41%" valign="top" bgcolor="#EFE2D3"><table width="100%" height="80" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20"><div class="tahoma11" id="txtEstado"></div></td>
</tr>
<tr>
<td height="20"><div class="tahoma11" id="txtCidade"></div></td>
</tr>
<tr>
<td height="20"><div class="tahoma11" id="txtRg"></div></td>
</tr>
<tr>
<td height="20"><div class="tahoma11" id="txtFone"></div></td>
</tr>
</table></td>
</tr>
<tr>
<td height="256" colspan="4" valign="top" class="tahoma11"><br />
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="4" bgcolor="#EFE2D3" class="tahoma11"><strong> Dados do Produto : </strong></td>
</tr>
<tr>
<td width="15%" align="right" class="tahoma11">Produto: </td>
<td width="36%">
<select name="select" onchange="pesquisar_dado( this.value )">
<option></option>
<?php
$consulta = mysql_query("SELECT * FROM tbProdutos ORDER BY NomeProd ASC");
while( $row = mysql_fetch_assoc($consulta) )
{
echo "<option value=\"{$row['IdProd']}\">{$row['NomeProd']}</option>\n";
}
?>
</select></td>
<td width="8%" align="right" class="tahoma11">Codigo: </td>
<td width="41%"><div class="tahoma11" id="CodProd"></div></td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#EFE2D3" class="tahoma11"><table width="100%" height="64" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20" align="right" class="tahoma11"> Nome:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">Tamanho:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11">Quantidade:</td>
</tr>
</table></td>
<td valign="top" bgcolor="#EFE2D3"><table width="100%" height="64" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="NomeProd"></div></td>
</tr>
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtTamanho"></div></td>
</tr>
<tr>
<td height="20" class="tahoma11"><label>
<input name="quantidade" type="text" class="tahoma11" id="quantidade" size="6" />
</label></td>
</tr>
</table></td>
<td align="right" valign="top" bgcolor="#EFE2D3" class="tahoma11"><table width="100%" height="43" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20" align="right" class="tahoma11"> LP:</td>
</tr>
<tr>
<td height="20" align="right" class="tahoma11"> Preço:</td>
</tr>
</table></td>
<td valign="top" bgcolor="#EFE2D3"><table width="100%" height="43" border="0" cellpadding="1" cellspacing="1">
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtLP"></div></td>
</tr>
<tr>
<td height="20" class="tahoma11"><div class="tahoma11" id="txtPreco"></div></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="4" align="right" valign="top" bgcolor="#EFE2D3" class="tahoma11"><label>
<input name="NomeProd" type="hidden" id="NomeProd" value="<? echo $row['NomeProd'] ?>" />
<input name="txtPreco" type="hidden" id="txtPreco" value="300" />
<input name="txtStatus" type="hidden" id="txtPreco" value="<? echo $txtStatus ?>" />
<input type="image" name="imageField" src="../images/btnAdiciona.jpg" />
</label></td>
</tr>
<tr>
<td colspan="4" align="right" valign="top" class="tahoma11"> </td>
</tr>
<tr>
<td colspan="4" valign="top" bgcolor="#EFE2D3" class="tahoma11"><strong> Produtos no Carrinho: </strong></td>
</tr>
</table></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
pagina que faz o calculo da comprar e gera uma session
<?PHP
//INICIALIZA A SESSÃO
session_start();
//RECEBE AS VARIÁVEIS
$v_prod = $_POST["NomeProd"];
$txtPreco = 300;
//echo $txtPreco;
$quantidade = $_POST["quantidade"];
//echo $quantidade;
$porcento = $_POST["txtStatus"];
//echo $porcento;
$preco2 = $txtPreco * $quantidade;
$PrecoFinal = $preco2 + ($preco2 * $porcento/100);
echo $PrecoFinal;
/*/PEGA A CHAVE DO ARRAY
$chave = array_keys($v_prod);
//EXIBE
for($i=0; $i<sizeof($chave); $i++) {
$indice = $chave[$i];
//VERIFICA
if(!empty($v_prod[$indice][QTDE]) ) {
//GRAVA NO ARRAY CESTA
$cesta[$indice][IdProd] = $v_prod[$indice][IdProd];
$cesta[$indice][CodProd] = $v_prod[$indice][CodProd];
$cesta[$indice][NomeProd] = $v_prod[$indice][NomeProd];
$cesta[$indice][txtLP] = $v_prod[$indice][txtLP];
$cesta[$indice][txtTamanho] = $v_prod[$indice][txtTamanho];
$cesta[$indice][txtPreco] = $v_prod[$indice][txtPreco];
$cesta[$indice][PrecoFinal] = $v_prod[$indice][PrecoFinal];
}//FECHA IF
}//FECHA FOR
//GRAVA NA SESSÃO
@$_SESSION[cesta] .= $cesta;*/
?>
Como é ajax e eu estou usando div não estou conseguindo passar alguns varoles para essa pagina alguém pode me ajudar com os dois problemas?? obrigado