PHP - paso de variables

 
Vista:
sin imagen de perfil

paso de variables

Publicado por jhon (26 intervenciones) el 15/12/2010 07:59:26
HOLA :

NECESITO CONOCER COMO RECARGAR VARIABLES STRING QUE EMPIEZAN POR 0

AQUI ESTA EL CODIGO:

<?PHP
$Depto=(isset($_GET['Depto']))?$_GET['Depto']:"0";

<!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>
<script language="javascript" type="">
function restauravalor(){
var Depto = String(<?php echo $Depto ?>);
document.getElementById("Depto").value = Depto;
alert(String(<?php echo $Depto ?>));
}

function enviarparametro(valor){
location = location.pathname + '?Depto=' + valor;
}
window.onload = function(){
document.getElementById('Depto').onchange = function(){
enviarparametro(this.value);
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>
<body class="fondo" onload="javascript:restauravalor();">
<form id="form1" name="form1" method="post" action="guardaips.php">
<table width="569" border="0" class="INTRANET" >
<tr>
<td> </td>
<td> </td>
<td><P>DEPARTAMENTO</P></td>
<td><select name="Depto" id="Depto" onchange="javascript:enviarparametro(this.value);">
<option value="0" id="0">Seleccione</option>

<?php
$link=mysql_pconnect("localhost","root","");
$resultados = mysql_select_db("NOMBRETABLA",$link);
$query="SELECT * FROM Depto ORDER BY Depto";
$response = mysql_query($query,$link);
$c=1;
while($row = mysql_fetch_assoc($response)) {
echo " <option value=\"".$row["idDepto"]."\">".$row["Depto"]."</option>\n";
$c++;
}
?>
</select></td>
<td> </td>
</tr>
</table>
</form>
?>

El select me permite escoger un departamento o provincia, la clasificación de estos esta normativizada y muchos de ellos empiezan en "0" Ej : Antioquia ="05", me recarga la pagina y en la variable $Depto la pasa como "5"

ya probe con:

$Depto=(string)(isset($_GET['Depto']))?$_GET['Depto']:"0";
y
$Depto=(string)(isset($_GET['Depto']))?(string)$_GET['Depto']:"0";

pero ninguno de los dos funciona .

Alguien que me pueda colaborar......
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder