Ir para conteúdo

POWERED BY:

Arquivado

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

Pedroalves

[Resolvido] Problema com procura em java script

Recommended Posts

<?php require_once('../Connections/ola.php'); ?>

<?php

if (!isset($_SESSION)) {

session_start();

}

$MM_authorizedUsers = "2";

$MM_donotCheckaccess = "false";

 

// *** Restrict Access To Page: Grant or deny access to this page

function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {

// For security, start by assuming the visitor is NOT authorized.

$isValid = False;

 

// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.

// Therefore, we know that a user is NOT logged in if that Session variable is blank.

if (!empty($UserName)) {

// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.

// Parse the strings into arrays.

$arrUsers = Explode(",", $strUsers);

$arrGroups = Explode(",", $strGroups);

if (in_array($UserName, $arrUsers)) {

$isValid = true;

}

// Or, you may restrict access to only certain users based on their username.

if (in_array($UserGroup, $arrGroups)) {

$isValid = true;

}

if (($strUsers == "") && false) {

$isValid = true;

}

}

return $isValid;

}

 

$MM_restrictGoTo = "../CLIENTES/cliente_index.php";

if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {

$MM_qsChar = "?";

$MM_referrer = $_SERVER['PHP_SELF'];

if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";

if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)

$MM_referrer .= "?" . $_SERVER['QUERY_STRING'];

$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);

header("Location: ". $MM_restrictGoTo);

exit;

}

?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

}

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}

 

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

}

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}

 

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

}

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}

 

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

if (PHP_VERSION < 6) {

$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

}

 

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":

case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}

return $theValue;

}

}

$joindate=date("y-m-d h-m-s");

$month=substr ($joindate,5,2);

$date=substr($joindate,8,2);

$year=substr($joindate,0,4);

$hour=substr($joindate,11,2);

$minutes=substr($joindate,14,2);

$seconds=substr($joindate,17,4);

mysql_select_db($database_ola, $ola);

$query_Recordset1 = "SELECT Username FROM `user` where Username='".$_SESSION['MM_Username']."'";

$Recordset1 = mysql_query($query_Recordset1, $ola) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

$totalRows_Recordset1 = mysql_num_rows($Recordset1);

 

mysql_select_db($database_ola, $ola);

$query_Recordset2 = "SELECT user.tipo,tipo.NOME FROM user INNER JOIN tipo ON tipo.id_tipo =user.tipo WHERE user.Username='".$_SESSION['MM_Username']."' ";

$Recordset2 = mysql_query($query_Recordset2, $ola) or die(mysql_error());

$row_Recordset2 = mysql_fetch_assoc($Recordset2);

$totalRows_Recordset2 = mysql_num_rows($Recordset2);

 

$colname_Recordset3 = "-1";

if (isset($_GET['id'])) {

$colname_Recordset3 = $_GET['id'];

}

mysql_select_db($database_ola, $ola);

$query_Recordset3 = sprintf("SELECT * FROM compras WHERE id_compra = %s", GetSQLValueString($colname_Recordset3, "int"));

$Recordset3 = mysql_query($query_Recordset3, $ola) or die(mysql_error());

$row_Recordset3 = mysql_fetch_assoc($Recordset3);

$totalRows_Recordset3 = mysql_num_rows($Recordset3);

 

$colname_Recordset4 = "-1";

if (isset($_GET['id'])) {

$colname_Recordset4 = $_GET['id'];

}

mysql_select_db($database_ola, $ola);

$query_Recordset4 = sprintf("SELECT produtos.idprod,produtos.Nome,produtos.descricao,compraproduto.Quantidade,compraproduto.Iva,compraproduto.Preco_sem_iva,compraproduto.Valor_iva,compraproduto.Valor_com_iva,compraproduto.Preco_Total,compraproduto.id_compra FROM produtos INNER JOIN compraproduto ON produtos.idprod =compraproduto.id_produto INNER JOIN compras ON compras.id_compra=compraproduto.id_compra WHERE compraproduto.id_compra = %s", GetSQLValueString($colname_Recordset4, "int"));

$Recordset4 = mysql_query($query_Recordset4, $ola) or die(mysql_error());

$row_Recordset4 = mysql_fetch_assoc($Recordset4);

$totalRows_Recordset4 = mysql_num_rows($Recordset4);

 

$soma=1+1;

?>

<!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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Untitled Document</title>

<style type="text/css">

#apDiv1 {

position:absolute;

width:2132px;

height:101px;

z-index:1;

left: 0;

top: 0;

text-align: center;

font-size: xx-large;

}

#apDiv2 {

position:absolute;

left:832px;

top:77px;

width:389px;

height:222px;

z-index:2;

text-align: center;

}

</style>

<script src="../SpryAssets/SpryMenuBar.js" type="text/javascript"></script>

<script src="../SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

<style type="text/css">

#apDiv3 {

position:absolute;

left:0px;

top:76px;

width:131px;

height:500px;

z-index:3;

}

</style>

<style type="text/css">

#apDiv4 {

position:absolute;

left:2px;

top:103px;

width:2135px;

height:964px;

z-index:4;

text-align: center;

}

#apDiv5 {

position:absolute;

left:-3px;

top:1068px;

width:1242px;

height:33px;

z-index:5;

text-align: center;

font-weight: bold;

}

#apDiv6 {

position:absolute;

left:8px;

top:186px;

width:1378px;

height:37px;

z-index:6;

}

</style>

<link href="../SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />

<style type="text/css">

#apDiv7 {

position:absolute;

left:2px;

top:177px;

width:208px;

height:55px;

z-index:6;

}

#apDiv8 {

position:absolute;

left:3px;

top:235px;

width:208px;

height:25px;

z-index:7;

}

#apDiv9 {

position:absolute;

left:3px;

top:267px;

width:213px;

height:468px;

z-index:8;

}

</style>

<link href="../SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />

<style type="text/css">

#apDiv10 {

position:absolute;

left:416px;

top:403px;

width:836px;

height:564px;

z-index:9;

text-align: center;

}

</style>

<link href="../SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />

</head>

 

<body>

<div id="apDiv1">

<p>GESTSTOCKS</p>

</div>

<div id="apDiv4">

<ul id="MenuBar1" class="MenuBarHorizontal">

<li><a href="../logout.php">LOGOUT</a> </li>

<li><a class="MenuBarItemSubmenu" href="#">AREA FINANCEIRA</a>

<ul>

<li><a class="MenuBarItemSubmenu" href="#">COMPRAS</a>

<ul>

<li><a href="#">LISTAR COMPRA</a></li>

<li><a href="#">ALTERAR COMPRA</a></li>

<li><a href="#">ELIMINAR COMPRA</a></li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">VENDAS</a>

<ul>

<li><a href="#">NOVA FACTURA</a></li>

<li><a href="#">NOVO RECIBO</a></li>

<li><a href="#">NOVA VENDA A DINHEIRO</a></li>

<li><a href="#">ALTERAR FACTURA</a></li>

<li><a href="#">ALTERAR RECIBO</a></li>

<li><a href="#">ALTERAR VENDA A DINHEIRO</a></li>

<li><a href="#">LISTAR FACTURA</a></li>

<li><a href="#">LISTAR RECIBO</a></li>

<li><a href="#">LISTAR VENDA A DINHEIRO</a></li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">PRODUTOS</a>

<ul>

 

<li><a href="#">ALTERAR</a></li>

<li><a href="#">ELIMINAR</a></li>

<li><a href="pesquisa_produto.php">PROCURAR</a></li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">HISTORIAL</a>

<ul>

<li><a href="#"> VENDAS</a></li>

<li><a href="#"> COMPRAS</a></li>

<li><a href="#">TOTAL</a></li>

</ul>

</li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">CLIENTES</a>

<ul>

<li><a href="#">NOVO CLIENTE</a></li>

<li><a href="#">ALTERAR DADOS</a></li>

<li><a href="#" class="MenuBarItemSubmenu">LISTAR CLIENTE</a>

<ul>

<li><a href="#">HISTORICO DO CLIENTE</a></li>

</ul>

</li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">FORNECEDORES</a>

<ul>

<li><a href="#">NOVO FORNECEDOR</a></li>

<li><a href="#">ALTERAR DADOS</a></li>

<li><a href="#">LISTAR FORNECEDOR</a></li>

<li><a href="#">ELIMINAR FORNECEDOR</a></li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">RECLAMAÇÕES</a>

<ul>

<li><a href="#">VER RECLAMAÇÕES</a></li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">OPÇÕES</a>

<ul>

<li><a href="#">ALTERAR DADOS</a></li>

<li><a href="#">MUDAR PASSWORD</a></li>

</ul>

</li>

</ul>

<p> </p>

<p> NOVA COMPRA</p>

<p> </p>

<p> </p>

</div>

<div id="apDiv5">COPYRIGHT PEDRO ALVES</div>

<div id="apDiv7">

<p>NOME: <?php echo $row_Recordset1['Username']; ?></p>

</div>

<div id="apDiv8">TIPO: <?php echo $row_Recordset2['NOME']; ?></div>

<div id="apDiv9">

<ul id="MenuBar2" class="MenuBarVertical">

<li><a href="funcionario_index.php">PAGINA PRINCIPAL</a></li>

<li><a class="MenuBarItemSubmenu" href="#">HORARIO</a>

<ul>

<li><a href="#">VER HORARIO</a></li>

<li><a href="#">ALTERAR HORARIO</a></li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">SOBRE A EMPRESA</a>

<ul>

<li><a href="#">VER SOBRE A EMPRESA</a></li>

</ul>

</li>

<li><a href="#" class="MenuBarItemSubmenu">MENSAGENS</a>

<ul>

<li><a href="#">ENVIAR MENSAGEM</a></li>

<li><a href="#">LISTAR MENSAGEM</a></li>

<li><a href="#">RASCUNHOS</a></li>

<li><a href="#">ELIMINAR MENSAGEM</a></li>

</ul>

</li>

</ul>

</div>

<div id="apDiv10"><script src="../Javascript/jquery.js"></script>

<script>

$(document).ready(function(){

$("input[name='suggest']").keyup(function(){

createList('.suggest');

$.ajax({

type: "GET",//apenas pra ficar mais fácil de debugar, pode mudar para POST depois

url: "function.php",

data: "parte="+$(this).val(),

success: function( data ){

$("#suggest").html( data );

}

});

});

 

$("#suggest a").live('click', function( e ){

e.preventDefault();

var href = $(this).attr('href');

var id = href.split('=');

 

$("input[name='id']").val( id[1] );

$("input[name='nome']").val( $(this).text() );

 

$("#suggest").remove();

});

$("#suggest").mouseout(function(){

$("#suggest").remove();

});

});

function createList( el )

{

$("#suggest").remove();

 

var list = document.createElement('ul');

list.id = 'suggest';

$( el ).append( list );

}

refresh ;

</script>

 

<form id="form1" name="form1" method="POST">

DATA

<span id="sprytextfield1">

<label for="text1"></label>

<input name="text1" type="text" id="text1" value="<?php echo $joindate=date("y-m-d");?>" size="8" readonly="readonly" />

<br />

<br />

<fieldset>

</fieldset>

 

<span class="textfieldRequiredMsg">A value is required.</span></span>

 

<p>

 

</p>

<p>

<label class="suggest">Nome

<input type="text" name="suggest" />

</label>

<label for="id">ID</label>

<input name="id" type="text" id="id" readonly="readonly" />

<label>Nome:

<input name="nome" type="text" readonly="readonly" />

<label>Preço:

<input name="preco" type="text" readonly="readonly" />

</label>

<script src="../Javascript/jquery.js"></script>

<script>

$(document).ready(function(){

$("input[name='suggest']").keyup(function(){

createList('.suggest');

$.ajax({

type: "GET",//apenas pra ficar mais fácil de debugar, pode mudar para POST depois

url: "Pesquisaproduto.php",

data: "parte="+$(this).val(),

success: function( data ){

$("#suggest").html( data );

}

});

});

 

$("#suggest a").live('click', function( e ){

e.preventDefault();

var href = $(this).attr('href');

var id = href.split('=');

 

$("input[name='id']").val( id[1] );

$("input[name='nome']").val( $(this).text() );

$("input[name='preco']").val( preco[1] );

$("input[name='Iva']").val( Iva[1] );

$("#suggest").remove();

});

$("#suggest").mouseout(function(){

$("#suggest").remove();

});

});

function createList( el )

{

$("#suggest").remove();

 

var list = document.createElement('ul');

list.id = 'suggest';

$( el ).append( list );

}

</script>

<p>

<p><span id="sprytextfield4">

<label for="text4">Quantidade</label>

<input type="text" name="text4" id="text4" />

IVA

<span class="textfieldRequiredMsg">A value is required.</span></span>

<label for="Iva"></label>

<input type="text" name="Iva" id="Iva" />

</p>

<span id="sprytextfield2"><span class="textfieldRequiredMsg">A value is required.</span></span>

<p>

<input type="submit" name="button2" id="button2" value="Aceitar" />

</p>

<input type="hidden" name="MM_update" value="form1" />

</form>

<p> 

<table border="1" align="center">

<tr>

<td>CODIGO </td>

<td>Nome</td>

<td>descricao</td>

<td>Quantidade</td>

<td>Iva</td>

<td>Preco_sem_iva</td>

<td>Valor_iva</td>

<td>Valor_com_iva</td>

<td>Preco_Total</td>

<td> </td>

</tr>

<?php do { ?>

<tr>

<td><?php echo $row_Recordset4['idprod']; ?><a href="pilas.php?recordID=<?php echo $row_Recordset4['idprod']; ?>"> </a></td>

<td><?php echo $row_Recordset4['Nome']; ?></td>

<td><?php echo $row_Recordset4['descricao']; ?></td>

<td><?php echo $row_Recordset4['Quantidade']; ?></td>

<td><?php echo $row_Recordset4['Iva']; ?></td>

<td><?php echo $row_Recordset4['Preco_sem_iva']; ?></td>

<td><?php echo $row_Recordset4['Valor_iva']; ?></td>

<td><?php echo $row_Recordset4['Valor_com_iva']; ?></td>

<td><?php echo $row_Recordset4['Preco_Total']; ?></td>

<td><a href="delt.php?id=<?php echo $row_Recordset4['idprod']; ?>"><img src="images/casa1.png" alt="ola" width="45" height="45" border="0" /></a></td>

</tr>

<?php } while ($row_Recordset4 = mysql_fetch_assoc($Recordset4)); ?>

</table>

<br />

<?php echo $totalRows_Recordset4 ?> Records Total

</p>

<p>

<label for="textfield3"><span id="spryselect1">SITUAÇÃO

<select name="select1" id="select1">

<option value="PAGO">PAGO</option>

<option value="NAO PAGO">NAO PAGO</option>

</select>

<span class="selectRequiredMsg">Please select an item.</span></span><br />

<br />

VALOR TOTAL</label>

</p>

<span id="sprytextfield3">

<label for="text3"></label>

<input name="text2" type="text" id="text3" value="<?php echo $soma?>" readonly="readonly" />

</span></p>

<p> </p>

<p>

<input type="submit" name="button" id="button" value="FINALIZAR COMPRA" />

</p>

</div>

<script type="text/javascript">

var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});

var MenuBar2 = new Spry.Widget.MenuBar("MenuBar2", {imgRight:"../SpryAssets/SpryMenuBarRightHover.gif"});

var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");

var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4");

</script>

</body>

</html>

<?php

mysql_free_result($Recordset1);

 

mysql_free_result($Recordset2);

 

mysql_free_result($Recordset3);

 

mysql_free_result($Recordset4);

?>

<?php require_once('../Connections/ola.php'); ?>

<?php

header("Content-Type: text/html; charset=ISO-8859-1");

 

echo suggest( getGet('parte') );

 

function suggest( $palavra )

{

$sql = "SELECT `idprod`, `Nome`,`Descricao`,`Iva`,`Preco_sem_iva` FROM produtos ";

if( !empty($palavra) )

$sql .= "WHERE `Nome` LIKE '{$palavra}%'";

 

$mysqli = new mysqli( 'localhost','root','123456','gest' );

$query = $mysqli->query( $sql );

if( $query->num_rows>0 )

{

$li='';

while( $dados = $query->fetch_object() )

$li .= '<li><a href="?id='.$dados->idprod .'">'.$dados->Nome.'</a></li>';

}

else

$li = 'Nenhum cadastro encontrado!';

 

return $li;

}

function getGet( $campo ){

return ( isset($_GET[ $campo ]) ) ? filter( $_GET[ $campo ] ) : null;

}

function filter( $var )

{

if( !get_magic_quotes_gpc() )

$str = mysql_real_escape_string( $var );

else

$str = $var;

$str = str_replace( '#', '\#', $str );

return $str;

}

ao fazer a pesquisa pelo nome so me mostra o nome e o id

Compartilhar este post


Link para o post
Compartilhar em outros sites

você precisa continuar a querystring:

href="?id='.$dados->idprod .'"
e fazer um parse dela.

 

 

http://forum.imasters.com.br/index.php?/topic/407094-autocomplete-simples/page__view__findpost__p__1598738

 

 

limpe teu código, está muito bagunçado.

nem peço créditos pelo meu script.. mas cuide bem dele.

Compartilhar este post


Link para o post
Compartilhar em outros sites

tem ficar assim certo mas mesmo assim não estou a conseguir por a funcionar

$li .= '<li><a href="?id='.$dados->idprod.'&Nome='.$dados->Nome.'&Descricao='.$dados->Descricao.'&Iva='.$dados->Iva.'">'.$dados->Preco_sem_iva.'</a></li>';

Compartilhar este post


Link para o post
Compartilhar em outros sites

tá... a query string você montou certo.

 

e o parser?

pegou o código do link que postei ?

Compartilhar este post


Link para o post
Compartilhar em outros sites

postei em #5

 

leia o link que postei.

Compartilhar este post


Link para o post
Compartilhar em outros sites

ja fiz alterações no javascript

mas mesmo assim ainda não esta a funcionar

<script src="../Javascript/jquery.js"></script>
  <script type="text/javascript"> 
function Querystring(qs) { // optionally pass a querystring to parse
        this.params = {};
        
        if (qs == null) qs = location.search.substring(1, location.search.length);
        if (qs.length == 0) return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
        qs = qs.replace(/\+/g, ' ');
        var args = qs.split('&'); // parse out name/value pairs separated via &
        
// split out each name=value pair
        for (var i = 0; i < args.length; i++) {
                var pair = args[i].split('=');
                var name = decodeURIComponent(pair[0]);
                
                var value = (pair.length==2)
                        ? decodeURIComponent(pair[1])
                        : name;
                
                this.params[name] = value;
        }
}

Querystring.prototype.get = function(key, default_) {
        var value = this.params[key];
        return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
        var value = this.params[key];
        return (value != null);
}
</script>
<script type="text/javascript"> 
        $(document).ready(function(){
                $("input[name='suggest']").keyup(function(){
                        createList('.suggest');
                        $.ajax({
                                type: "GET",//apenas pra ficar mais fácil de debugar, pode mudar para POST depois
                                url: "Pesquisaproduto.php",
                                data: "palavra="+$(this).val(), 
                                success: function( data ){
                                        $("#suggest").html( data );
                                }
                        });
                });
                
                $("#suggest a").live('click', function( e ){
                        e.preventDefault();
                        
                        var href = $(this).attr('href');        
                        //isso é do original
                        var id = href.split('=');

                        alert( href );
                        
                        var qs = new Querystring( href );
                        
                        alert( qs.get('Iva') );
                       // alert( qs.get('login') );        
                        
                        //isso é do original
                        $("input[name='id']").val( idprod[1] );

      
                        $("input[name='Nome']").val( $(this).text() );
                        $("input[name='Descricao']").val( $(this).text() );
                        $("input[name='Iva']").val( qs.get('Iva') );
                        $("input[name='Preco']").val( qs.get('Preco_sem_iva') );

                        
                        $("#suggest").remove();
                });
                $("#suggest").mouseout(function(){
                        $("#suggest").remove();
                });
        });

        function createList( el )
        {
                $("#suggest").remove();
                
                var list = document.createElement('ul');
                list.id = 'suggest';
                $( el ).append( list );
        }
</script>

Compartilhar este post


Link para o post
Compartilhar em outros sites

legal... está voltando certo o alert?

alert( qs.get('Iva') );
?

e o

alert( href );
?

 

você tá no caminho cara...

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.