mm pues por lo que entendí hice esto pero sigue sin funcionar,no se queda la seleccion al darle al submit, lo que pasa es que yo muestro el resultado de la consulta que viene de otra pagina con un include para que se muestra en la misma no se si esto influya o no hice bien el select
dejo el código que tengo, los text si me los conserva
Código PHP:
<?
session_start();
include("conexion.php");
?>
<html>
<head>
<title>..::::..</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<link rel="stylesheet" type="text/css" media="all" href="calendario/calendar-win2k-cold-1.css" title="win2k-cold-1" />
<script type="text/javascript" src="calendario/calendar.js"></script>
<script type="text/javascript" src="calendario/calendar-es.js"></script>
<script type="text/javascript" src="calendario/calendar-setup.js"></script>
<script type="text/javascript" src="ajax2.js"></script>
<script type="text/javascript">
</head>
<body>
<div>
<?php
/*
En tu while verifica el valor que quieres seleccionar usando un if()
y posteriormente le agregas el atributo selected al <option> que quieras seleccionar, por ejemplo:
*/
$sSQL="SELECT * FROM tipo_sistemas ";
$result=mysql_query($sSQL);
echo " <SELECT name='id_sistema'>";
while ($row = mysql_fetch_array($result)) {
if ($row['SISTEMA'] == $row['id_sistema']) {
echo "<option selected=\"selected\" value=\'".$row['id_sistema']."'>".$row['SISTEMA']."</option>";
} else {
echo "<option value=\'".$row['id_sistema']."'>".$row['SISTEMA']."</option>";
}
}
echo "</select>";
mysql_free_result($result);
//$sistema =$_POST['id_sistema'];
?>
<form name="form1" method="post" action="<?php echo $PHP_SELF;?>">
<label>
<p> </p>
<div align="left">
<h1>Busqueda Entre Fechas</h1>
<table width="758" height="58">
<tr>
<th width="86" scope="col">Desde</th>
<th width="199" scope="col"><input type="text" name="desdeF" id = "desdeF" value="<?=$_POST['desdeF']?>" > <img src="img/calendar.gif" id="btn_desde" alt="calendario" align="texttop"/>
<script type="text/javascript">
Calendar.setup(
{
inputField : "desdeF", // ID of the input field
showsTime : true,
ifFormat : "%Y-%m-%d %I:%M:%S ", // the date format
button : "btn_desde" // ID of the button
}
);
</script></th>
<th width="86" scope="col">Hasta</th>
<th width="199" scope="col"><input type="text" name="hastaF" id = "hastaF" value="<?=$_POST['hastaF']?>" > <img src="img/calendar.gif" id="btn_hasta" alt="calendario" align="texttop"/>
<script type="text/javascript">
Calendar.setup(
{
inputField : "hastaF", // ID of the input field
ifFormat : "%Y-%m-%d %I:%M:%S", // the date format
showsTime : true,
button : "btn_hasta" // ID of the button
}
);
</script></th>
<th width="158" scope="col"><input type="submit" name="Submit" value="Buscar"></th>
</tr>
</table>
</label>
</form>
</div>
<?php
if ((isset($_POST['desdeF'])) && (strlen($_POST['hastaF'])) || isset($_GET['pos']) || isset($_GET['ord'])){
if ($_POST['desdeF']!="" ){
$_SESSION['desdeF']=$_POST['desdeF'];
$_SESSION['hastaF']=$_POST['hastaF'];
// $_SESSION["sistemas"]=$_POST['id_sistema'];
}
include("buscarFechas.php");
}else{ if (isset($_POST['desdeF'])){echo '<p class="info">Debe de poner las 2 fechas</p>';}}
?>
</body>
</html>