Ver Mensaje Individual
  #3 (permalink)  
Antiguo 06/10/2018, 15:17
helenp
 
Fecha de Ingreso: mayo-2009
Mensajes: 382
Antigüedad: 14 años, 10 meses
Puntos: 6
Respuesta: Guardar como array javascript de xml con php

Ya está funcionando:
Código PHP:
Ver original
  1. $xml = new SimpleXMLElement($viajes);
  2.     $tmpArrayFechas = [];
  3.     foreach ($xml->excursion as $excursion) {
  4.     if ($excursion->idmodelo == $cifraexcursion) {
  5.     $tmpArrayFechas[] = $excursion->fecha;
  6.      }
  7.     }
  8.     $tmpArrayFechas = implode(',', $tmpArrayFechas);
  9.     ?>
  10.     <input type="hidden" id="plazasDisponibles"
  11.      name="plazasDisponibles"
  12.     value="<?php echo $tmpArrayFechas; ?>">
  13.     <script>
  14.  
  15.     var arrayDiasDisponibles =
  16.     document.querySelector("#plazasDisponibles").value.split(',');
  17.     $('input').datepicker({
  18.     beforeShowDay: function(date){
  19.     var string = jQuery.datepicker.formatDate('yy-mm-dd', date);
  20.     return [ arrayDiasDisponibles.indexOf(string) !== -1 ]
  21.     }
  22.     });
  23.  
  24.     (function() {
  25.     $.datepicker.setDefaults({
  26.     regional: 'en',
  27.     buttonImage: "/images/calendar_blue.png",
  28.     buttonImageOnly: true,
  29.       firstDay: 1,
  30.     })
  31.     })();
  32.     </script>