Ver Mensaje Individual
  #7 (permalink)  
Antiguo 21/04/2007, 10:45
ozk4r
 
Fecha de Ingreso: febrero-2004
Ubicación: En Copiapó
Mensajes: 52
Antigüedad: 21 años
Puntos: 0
Re: Obtener solo el numero de un input

Gracias por ayudarme dejo mi codigo por si es que alguien lo necesita

archivo facturacion.php
Código:
<script>
	var ajaxp = new sack();
	var currentProductID=false;
	function getProductData(valor_campo,nombre_campo)
	{
		var numero = nombre_campo;
		var	numero = numero.replace(/\D/g,'');
		var codigo_producto = valor_campo;
		var detalle_producto = "detalle_producto"+numero;
		if(codigo_producto.length>4 && codigo_producto!=currentProductID){
			currentProductID = codigo_producto
			ajaxp.requestFile = 'getProd.php?codigo_producto='+codigo_producto+'&detalle_producto='+detalle_producto;
			ajaxp.onCompletion = showProductData;
			ajaxp.runAJAX();		
			}
		
	}
	
	function showProductData()
	{
		var formObjp = document.forms['clientForm'];	
		eval(ajaxp.response);
	}
	
</script>
archivo getProd.php

Código:
<?php
header("Content-Type: text/html; charset=iso-8859-1"); 
/* Replace the data in these two lines with data for your db connection */
$connection = mysql_connect("localhost","usuario","password");  
mysql_select_db("rcinvoices",$connection);

if(isset($_GET['codigo_producto'])){  
  $res = mysql_query("select * from tbl_productos where codigo_producto='".$_GET['codigo_producto']."'") or die(mysql_error());
  if($inf = mysql_fetch_array($res)){
    echo "formObjp.".$_GET["detalle_producto"].".value = '".$inf["detalle_producto"]."';\n";    
  }else{
    echo "formObjp.".$_GET["detalle_producto"].".value = '';\n";    
  }    
}
?>
Lo que hace es tomar el valor de un input, nombre y realiza una busqueda en una bd mysql y devuelve el valor en el input especificado.

Gracias a todos los que cooperaron
__________________
:pirata: