0

背景:我正在为我医院的手术室创建一个 php 生成的轮班调度程序。在 X 轴上我正在绘制天数,在 Y 轴上是 OR。我正在使用 Jeditable 就地编辑每个单元格,从加载数据的选择中生成一个下拉列表。

php代码:

$query = $db->query('select sp.id, sp.sigla from lista_specializzandi sp where sp.id not in (select sp.id from lista_specializzandi sp, esigenze e where sp.id = e.specializzando and e.giorno='.$giorno.' and (e.tipologia=2 or e.tipologia=3 or e.tipologia=4 or e.tipologia =5 or e.tipologia=6 or e.tipologia=7))');
$esiSelect = array();
while ($disp = $db->fetch_array($query)) {
    $esiSelect[$disp['id']] = $disp['sigla'];
}

Javascript:

<script>
    $(document).ready(function() {
    $(".turnistica").editable('save_turnistica.php', {
      data        : <?php echo json_encode($esiSelect); ?>,
      type        : 'select',
      indicator   : 'Salvo...',
      tooltip   :   'Clicca per modificare',
      placeholder   :   '&nbsp;',
      onblur    :   'submit',
      event     :   'click',
      submitdata : function(value, settings) {
        return {"giorno" : $(this).attr('id_giorno'), "sala" : $(this).parent().attr('id_riga')};
      }
    });
  });  
    </script>

桌子:

<section class="fluid" id="flip-scroll">
            <table id="foglioEsigenze" class="table-bordered table-striped table-condensed cf full">
            <col class="col10">
            <?php 
foreach ($cals as $c)
        echo
        '<col class="dw'.$c->isFeriale.$c->isFestivo.'"></col>';
?>
              <thead class="cf verde_trasp bold text-white">
                  <tr>
            <th class="col1">&nbsp;</th>
            <?php 
foreach ($cals as $c)
        echo
        '<th class="dw'.$c->isFeriale.$c->isFestivo.'"><span style="font-size:9px">'.substr($c->giornoNome, 0, 3).'</span> '.$c->d.'</th>';
?>
          </tr>
              </thead>
                <tbody>

          <?php
while ($s = $db->fetch_array($indice)) {
        echo
        '<tr class="Row" data-blocco="'.$s['blocco'].'" id_riga="'.$s['id'].'"><td style="text-align: left;">'.$s['sigla'].'</td>';
        foreach ($cals as $g) {
        echo
        '<td class="turnistica" style="text-align: center;" id_giorno="'.$g->id.'">';
        global $db;
        $sql = 'select sp.sigla from turnistica t, lista_specializzandi sp where t.giorno = '.$g->id.' and t.riga='.$s['id'].' and t.specializzando = sp.id limit 1';
        $query = $db->query($sql);
        $sigla = $db->fetch_array($query);
        echo $sigla['sigla'];
        '</td>';
        '</tr>';            
        }
}
?>
                </tbody>
      </table>
    </section>

... 到目前为止,一切都很好!现在我需要创建一个下拉菜单,在我将医生插入一列后自动删除它们。我想到了这个解决方案,但我不知道为什么它不起作用。

1)我将所有加载代码移至外部 php 文件:

<?php  

require ('includes/initialise.php');  
global $db;
$giorno     = $_GET['giorno'];


$query = $db->query('select sp.id, sp.sigla from lista_specializzandi sp where sp.id not in (select sp.id from lista_specializzandi sp, esigenze e where sp.id = e.specializzando and e.giorno='.$giorno.' and (e.tipologia=2 or e.tipologia=3 or e.tipologia=4 or e.tipologia =5 or e.tipologia=6 or e.tipologia=7))');
$esiSelect = array();
while ($disp = $db->fetch_array($query)) {
    $esiSelect[$disp['id']] = $disp['sigla'];
}
echo json_encode($esiSelect);

?>

2)我在javascript中通过loadurl调用它,添加元素的属性

loadurl        : "disponibili.php?giorno=" + $(this).attr("id_giorno"),

所有问题都来自我传递的 Javascript 变量。但是我google了很多,没有解决问题。

我怎样才能解决这个问题?

@dcaswell:我无法将 2) 中的 javascript 变量传递给 loadurl 文件,因此在填充 json 列表之前无法执行任何操作。我肯定错过了一些东西。任何帮助将非常感激。谢谢

4

0 回答 0