如何根据选择的其他选项更改选择选项?

时间:2020-07-03 14:04:16

标签: php jquery json ajax api

我需要选择时生成的pdf路径文件:

     1- Type document
     2- Date
     3- Unity
    
    Type: 1 - 2 - 3
    Unity: A - B - C
    Date: yyyy/m/d

这是我的代码,用于管理信息,所有数据都使用cookie存储。

这是PHP文件-file.php:

<select id="diretorioArquivo" name="diretorioArquivo" class="" onChange=""abrir.location = options[selectedIndex].value">
      <option class="dropdown-item" selected disabled>Selecione um arquivo...</arquivo>
    
    <?php
    $data_unidade = $_COOKIE['data_unidade'];
    $tipo_arquivo = $_COOKIE['tipo_arquivo'];
    $id_unidade = $_COOKEI['id_unidades'];
    
    $urlPdf = 'http://localhost'.$data_unidade.'&tipo_arquivo='.$tipo_arquivo.&unidade_id='.$id_unidade;
    $recolhePdf = file_get`enter code here`_contents($urlpdf);
    $resultPdf = json_decode($recolhePdf);
    foreach($resultPdf as $pdf) {
    ?>
    
       <option id="<?php echo $pdf->id. ?>" value="localhost/arquivos/<?php echo $pdf->caminho; ?>"
       class=""<?php echo $pdf->caminho; ?></option>
    <?php
    }
    ?>
    </select>

    <!-- USING JQUERY -->
    <script>
      $('#diretorioArquivo').on('change', function() {
        var src=$(this).find('option:selected').val();
        $('#abrir').attr('src', src);
      });
    </script>

0 个答案:

没有答案