Foros del Web » Programando para Internet » PHP »

Pasar valor a textbox

Estas en el tema de Pasar valor a textbox en el foro de PHP en Foros del Web. HOLA AMIGOS FOREROS: Tengo el siguiente problema que me esta matando la cabeza . Tengo la pagina buscador.php que al ingresar un valor mientras voy ...
  #1 (permalink)  
Antiguo 27/04/2010, 21:45
 
Fecha de Ingreso: marzo-2009
Mensajes: 46
Antigüedad: 15 años, 1 mes
Puntos: 1
Pasar valor a textbox

HOLA AMIGOS FOREROS:
Tengo el siguiente problema que me esta matando la cabeza . Tengo la pagina buscador.php que al ingresar un valor mientras voy escribiendo abajo me muestra las coincidencias. Por ejemplo, ingreso el codigo 1.00 en el textbox y abajo me muestra en una tabla la descripcion CONSULTA y el importe de la misma 7.00 pesos.
Lo que necesito es pasar ese importe ($7.00) a un textbox (llamado ARANCEL) que tengo en la misma pagina o tomar ese valor para despues multiplicarlo por la cantidad de CONSULTAS.

Les dejo el codigo:

BUSCADOR.PHP
Código PHP:
<?php
require('config.php');
require(
'include/conexion.php');
require(
'include/funciones.php');

if(isset(
$_GET['q']) and !eregi('^ *$',$_GET['q'])){
        
$q sql_quote($_GET['q']); //para ejecutar consulta
        
$busqueda htmlentities($q); //para mostrar en pantalla

        
$sqlStr "SELECT * FROM nomhospital where (codigo='".$q."')";
        
$sqlStrAux "SELECT count(*) as total FROM nomhospital where (codigo='".$q."')";
    }else{
        
$sqlStr "SELECT * FROM nomhospital";
        
$sqlStrAux "SELECT count(*) as total FROM nomhospital";
    }

$aux Mysql_Fetch_Assoc(mysql_query($sqlStrAux,$link));
$query mysql_query($sqlStr.$limit$link);
?><!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>Buscador en AJAX</title>
<link rel="stylesheet" href="pagination.css" media="screen">
<link rel="stylesheet" href="style.css" media="screen">
<script src="include/buscador.js" type="text/javascript" language="javascript"></script>
</head>

<body>
    <form action="index.php" onsubmit="return buscar()">
      <label>Buscar</label> <input type="text" id="q" name="q" value="<?php if(isset($q)) echo $busqueda;?>" onKeyUp="return buscar()">
Arancel      <span id="loading"></span>
      <label for="textfield"></label>
      <input type="text" name="ARANCEL" id="ARANCEL"  value="<? echo($valor);?>" />
    </form>
    
    <div id="resultados">
    <p><?php
        
if($aux['total'] and isset($busqueda)){
                echo 
"{$aux['total']} Resultado".($aux['total']>1?'s':'')." que coinciden con tu b&uacute;squeda \"<strong>$busqueda</strong>\".";
            }elseif(
$aux['total'] and !isset($q)){
                echo 
"Total de registros: {$aux['total']}";
            }elseif(!
$aux['total'] and isset($q)){
                echo
"No hay registros que coincidan con tu b&uacute;squeda \"<strong>$busqueda</strong>\"";
            }
    
?></p>

    <?php 
        
if($aux['total']>0){
            echo 
"\t<table class=\"registros\">\n";
            echo 
"<tr class=\"titulos\"><td>Titulo</td></tr>\n";
            
$r=0;
            while(
$row mysql_fetch_assoc($query)){
          echo 
"\t\t<tr class=\"row$r\"><td>".htmlentities($row['descripcion'])."</a></td><td>".htmlentities($row['arancel'])."</a></td></td>\n";
             
$valor$row['arancel'];
          if(
$r%2==0)++$r;else--$r;
        }
            echo 
"\t</table>\n";
        }
    
?>
    </div>
</body>
</html>
BUSQUEDA.PHP
Código PHP:
<?php
require('config.php');
require(
'include/conexion.php');
require(
'include/funciones.php');

if(isset(
$_GET['q']) and !eregi('^ *$',$_GET['q'])){
        
$q sql_quote($_GET['q']); //para ejecutar consulta
        
$busqueda htmlentities($q); //para mostrar en pantalla

        
$sqlStr "SELECT * FROM nomhospital WHERE (codigo='".$q."')";
        
$sqlStrAux "SELECT count(*) as total FROM nomhospital WHERE (codigo='".$q."')";
    }else{
        
$sqlStr "SELECT * FROM nomhospital";
        
$sqlStrAux "SELECT count(*) as total FROM nomhospital";
    }

$aux Mysql_Fetch_Assoc(mysql_query($sqlStrAux,$link));
$query mysql_query($sqlStr.$limit$link);
?>    <p><?php
        
if($aux['total'] and isset($busqueda)){
                echo 
"{$aux['total']} Resultado".($aux['total']>1?'s':'')." que coinciden con tu b&uacute;squeda \"<strong>$busqueda</strong>\".";
            }elseif(
$aux['total'] and !isset($q)){
                echo 
"Total de registros: {$aux['total']}";
            }elseif(!
$aux['total'] and isset($q)){
                echo
"No hay registros que coincidan con tu b&uacute;squeda \"<strong>$busqueda</strong>\"";
            }
    
?></p>

    <?php 
        
if($aux['total']>0){
            echo 
"\t<table class=\"registros\">\n";
            echo 
"<tr class=\"titulos\"><td>Titulo</td></tr>\n";
            
$r=0;
            while(
$row mysql_fetch_assoc($query)){
          echo 
"\t\t<tr class=\"row$r\"><td>".htmlentities($row['descripcion'])."</a></td><td>".htmlentities($row['arancel'])."</a></td></td>\n";
            
$valor$row['arancel'];
          if(
$r%2==0)++$r;else--$r;
        }
            echo 
"\t</table>\n";
        }
    
?>
CONFIG.PHP
Código PHP:
<?php
    $host 
"localhost";
    
$user "USUARIO";
    
$pass "CONTRASEÑA";
    
$db "clinica";
?>
FUNCIONES.PHP
Código PHP:
<?php
function sql_quote$value )
{
    if( 
get_magic_quotes_gpc() )
    {
          
$value stripslashes$value );
    }
    
//check if this function exists 
    
if( function_exists"mysql_real_escape_string" ) )
    {
          
$value mysql_real_escape_string$value );
    }
    
//for PHP version < 4.3.0 use addslashes 
    
else
    {
          
$value addslashes$value );
    }
    return 
$value;
}
?>
SALUDOS Y ESPERO SU AYUDA.

Etiquetas: pasar, textbox
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:01.