Foros del Web » Programando para Internet » PHP »

Problema Formato Rut y Funcion

Estas en el tema de Problema Formato Rut y Funcion en el foro de PHP en Foros del Web. Bueno tengo un problema en un input Código PHP: < FORM ACTION = "index.php"  method = "POST"  class= "style6" >         < TABLE width = "238" >           < ...
  #1 (permalink)  
Antiguo 25/12/2007, 12:32
 
Fecha de Ingreso: diciembre-2007
Mensajes: 15
Antigüedad: 16 años, 4 meses
Puntos: 0
Problema Formato Rut y Funcion

Bueno tengo un problema en un input
Código PHP:
<FORM ACTION="index.php" method="POST" class="style6">
        <
TABLE width="238">
          <
TR>
            <
TD width="108" class="style11"><div align="right"><span class="style13">R.U.T.:</span></div></TD>
            <
TD width="118" class="style11"><INPUT NAME="rut22" TYPE="text" SIZE="10" MAXLENGTH="20" onblur="this.value = formato_rut(this.value, true)">
              <
input type="image" style="" src="imagenes/bot_lupa1.gif" name="accion22" value="Buscar" >              </a></TD>
          </
TR>
        </
TABLE>
      </
FORM
tengo eso que autorellena el rut con puntos y el guion
La funcion es esta a la que llama:

Código PHP:
<script>
function 
formato_rut(textoactivo) {
var 
invertido "";
var 
dtexto "";
var 
cnt 0;
var 
i=0;
var 
j=0;
var 
largo "";    
    if (
activo) {
          
texto formato_rut(textofalse)
          
largo texto.length;
          for ( 
i=(largo-1),j=0i>=0i--,j++ )
            
invertido invertido texto.charAt(i);          
          
dtexto dtexto invertido.charAt(0);
          
dtexto dtexto '-';          
          for ( 
i=1,j=2i<largoi++,j++ )
          {
            
//alert("i=[" + i + "] j=[" + j +"]" );
            
if ( cnt == )
            {
              
dtexto dtexto '.';
              
j++;
              
dtexto dtexto invertido.charAt(i);
              
cnt 1;
            }
            else
            { 
              
dtexto dtexto invertido.charAt(i);
              
cnt++;
            }
          }
          
invertido "";
          for ( 
i=(dtexto.length-1),j=0i>=0i--,j++ )
            
invertido invertido dtexto.charAt(i);
          if (
invertido == '-'invertido ""
          
texto invertido;
    } else {
        var 
tmpstr "";
        for ( 
i=0texto.length i++ )
        if ( 
texto.charAt(i) != ' ' && texto.charAt(i) != '.' && texto.charAt(i) != '-' )
            
tmpstr tmpstr texto.charAt(i);
        
texto tmpstr;
    }
    return 
texto;
}
</script> 
Lo malo es q no me funciona lo siguiente porque al ingresar el rut y ya haberlo arreglado y al apretar el boton deberian entrarme a la siguiente sentencia pero no lo hace ( no hace nada ) no tira ningun mensaje ( se actualiza la pagina no mas ) :

Código PHP:
 include ('bddef.php');
if (isset (
$_POST['rut']))
{
$rut $_POST['rut'];
//$rut =strtoupper(ereg_replace('\.|,|-','',$rut));
$sql="select * from cliente where RUT='$rut'";
$result mysql_query($sql,$dbc);
$row mysql_fetch_assoc($result);
    if(
$row)
    {
    echo 
"<b>Nº SOCIO: </b>".$row['NSOCIO']." <b>RUT:</b> ".$row['RUT']." <b>NOMBRE:</b> ".$row['NOMBRE']." <b>SU PUNTAJE ES:</b> ".$row['PTOS'];
    }else{
    echo 
"Rut No Ingresado en Nuestra Base de Datos";
    } 

Espero que me puedan ayudar de antemanos Muchas Gracias
  #2 (permalink)  
Antiguo 25/12/2007, 12:40
 
Fecha de Ingreso: noviembre-2002
Mensajes: 1.341
Antigüedad: 21 años, 5 meses
Puntos: 17
Re: Problema Formato Rut y Funcion

Código PHP:

if (isset ($_POST['rut'])) 
¿Hay algún campo del formulario que se llame así?
  #3 (permalink)  
Antiguo 25/12/2007, 12:46
 
Fecha de Ingreso: diciembre-2007
Mensajes: 15
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Problema Formato Rut y Funcion

jajajajaj PROBLEMA RESULETO que lol no m fije que le habia puesto rut22 al formulario :D GRacias keysher
  #4 (permalink)  
Antiguo 25/12/2007, 14:02
 
Fecha de Ingreso: diciembre-2007
Mensajes: 15
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Problema Formato Rut y Funcion

Bueno mira lo estoy haciendo asi pero = necesito una ayuda
Código PHP:
 ?>
<input name="si" type="button" value="si">
<input name="no" type="button" value="no">
<?php
if(isset ()){
$query ="UPDATE cliente SET  PTOS='$puntos' WHERE RUT = '$rut2'"
$result mysql_query($query,$dbc);
}else{


}
Coloque dos Botones un si y un no

entonc coloque mas abajo un if el cual tiene que preguntar si fue presionado el si que entre al if y si fue un no que se salga de la pagina y no haga nada .... mi pregunta es q coloco en el if para saber si apreto el si ???
  #5 (permalink)  
Antiguo 25/12/2007, 14:14
 
Fecha de Ingreso: diciembre-2007
Mensajes: 15
Antigüedad: 16 años, 4 meses
Puntos: 0
Re: Problema Formato Rut y Funcion

algo asi tambien habia pensado pero no funka falta algo nose .... HELPME :P

Código PHP:
<input name="si" type="button" value="<? echo $resp=1 ?>">
<input name="no" type="button" value="<? echo $resp=2 ?>">
<?php
if($resp == 1){
$query ="UPDATE cliente SET  PTOS='$puntos' WHERE RUT = '$rut2'"
$result mysql_query($query,$dbc);
}else if( 
$resp == 2){
$delay "0"
$url "/local/in_puntaje.php";
echo 
'<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
  #6 (permalink)  
Antiguo 25/12/2007, 14:18
 
Fecha de Ingreso: noviembre-2002
Mensajes: 1.341
Antigüedad: 21 años, 5 meses
Puntos: 17
Re: Problema Formato Rut y Funcion

Si usas JavaScript tienes que recargar la página. Ten en cuenta que PHP se ejecuta en el servidor y lo que hace es generar el código HTML que mandará al cliente. Y JavaScript se ejecuta en el cliente, por lo que no puedes usar código PHP como respuesta a un código de JS.

Lo que tienen que hacer los botones es un submit, y con ellos mandar algún dato (puede ser un campo oculto que contenga el valor de "sí" o "no". Y eso lo evaluas una vez se ha recargado la página.
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 09:07.