0

jqGrid といくつかのフィルター フィールド、2 つのコンボボックスと 2 つの jQuery-ui 日付ピッカーがあります。フィールドから値を投稿しようとすると、元の値しか取得できません。たとえば、私のコンボボックスは「all」オプションで始まり、その値は -1 で、どのオプションを選択しても -1 がポストされます。同じことが2つの日付ピッカーにも当てはまります。私は「」しか取得しません。

これは私のコードです:

<?php 
    require_once 'DAO/programaDAO.php';
?>

<script>

$(document).ready(function(){     

    $( "#buscarBtn" ).button().click(function(){
            $("#gdCiclos").trigger('reloadGrid');
    });

    $( "#from" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,    
      onClose: function( selectedDate ) {
        $( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#to" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      numberOfMonths: 3,
      onClose: function( selectedDate ) {
        $( "#from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });

    $(function () {
    $("#gdCiclos").jqGrid({
        url:'sampleData.php',
        postData: {fechafin:document.getElementById('to').value, fhechainicial:document.getElementById('from').value, programaSelect:document.getElementById('selectPrograma').value, estadoSelect:document.getElementById('selectEstado').value},
        datatype: 'json',
        mtype: 'POST',
        colNames:['Ciclo Nº','Fecha Inicio', 'Fecha Fin', 'Programa', 'Estado'],
        colModel:[
        {name:'Ciclo Nº', index:'id', width:80, resizable:false, align:"center"},
        {name:'Fecha Inicio', index:'FechaInicio', width:200,resizable:false, sortable:true},
        {name:'Fecha Fin', index:'FechaFin', width:200,resizable:false, sortable:true},
        {name:'Programa', index:'Programa', width:165,resizable:false, sortable:true},
        {name:'Estado', index:'Estado', width:165, sortable:true}
        ],       
        pager: "#pagerGdCiclos",
        rowNum: 30,
        rowList: [10, 30, 100],
        sortname: "FechaInicio",
        sortorder: "desc",
        viewrecords: true,
        gridview: true,
        autoencode: true,
        caption: "Ciclos",
        height:'auto'

    });
});

 });



</script>

<div id="filtrosBusqueda">
                <div id="divBusProg">
                <label id="labelPrograma" class="labelBusquedaItem">Programa: </label>
                <?php

                    $eqId = $_GET['eqId'];
                    $listaProgramas = getTiposProgramasByEquipo($eqId);
                    echo("<select id=\"selectPrograma\" class=\"selectBox\">");
                        echo '<option value="-1">Todos</option>';
                    foreach ($listaProgramas as $value) {
                        echo '<option value="'.$value['programa_id'].'">'.$value['descripcion'].'</option>';
                    }
                    echo("<select id=\"selectPrograma\">");
                ?>
             </div>

    <div id="divBusEst">

                <label id="labelPrograma" class="labelBusquedaItem">Estado: </label>
            <?php

                $listaEstados = getEstados();
                echo("<select id=\"selectEstado\" class=\"selectBox\">");
                    echo '<option value="-1">Todos</option>';
                foreach ($listaEstados as $value) {
                    echo '<option value="'.$value['ciclo_estado_id'].'">'.$value['descripcion'].'</option>';
                }
                echo("</select>");
            ?>
    </div>

    <div id="divBusRangoFecha">
        <label for="from" class="labelBusquedaItem">Desde: </label>
        <input type="text" id="from" name="from" class="selectBox" />
        <label for="to" class="labelBusquedaItem">Hasta: </label>
        <input type="text" id="to" name="to" class="selectBox" />
    </div>
    <a href="#" id="buscarBtn">Buscar</a>

    </div>
<div    id="gridBusqueda">
    <table id="gdCiclos"></table>
    <div id="pagerGdCiclos"> </div>
</div>
4

2 に答える 2

0

完了、問題はこの行でした

 postData: {fechafin:document.getElementById('to').value, fhechainicial:document.getElementById('from').value, programaSelect:document.getElementById('selectPrograma').value, estadoSelect:document.getElementById('selectEstado').value},

次のようにする必要があります。

postData: {fechainicial :function() { return document.getElementById('from').value;}, fechafin:function() { return document.getElementById('to').value;}, programaSelect:function() { return document.getElementById('selectPrograma').value;}, estadoSelect:function() { return document.getElementById('selectEstado').value;}},
于 2013-06-27T16:40:34.787 に答える
0

あなたの問題programaSelect:document.getElementById('selectPrograma').valueは、選択を作成するときに、それを閉じていない</select>、再作成している<select id=\"selectPrograma\">ため、最初ではなく2番目の値を取得していることです#selectPrograma-

echo("<select id=\"selectPrograma\" class=\"selectBox\">");
     echo '<option value="-1">Todos</option>';
foreach ($listaProgramas as $value) {
     echo '<option value="'.$value['programa_id'].'">'.$value['descripcion'].'</option>';
}
echo("<select id=\"selectPrograma\">");  <------- This line

最後の行を - に変更します

echo("</select>");
于 2013-06-27T13:06:11.110 に答える