Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
How to redirect page using targetURL with my datepicker

I am tweaking with Twisty's script - Using Jquery UI Datepicker to redirect to URL: Change URL value based on the selected date

I am trying let user click on a date which will be redirect to a page according to the date selected.

If user click on 18 January it should be redirected to datpicker.com/18-01-2022. If the date 22 March is selected it should go to datpicker.com/22-03-2022.

But I am getting this alert - Redirect to undefined, no matter how I tweaked the script. Hence, I would appreciate your help. Thank you.

Pick a date:

<script>
$(function() {
  function getDayOfYear(n) {
    var s = new Date(n.getFullYear(), 0, 0);
    var d = (n - s) + ((s.getTimezoneOffset() - n.getTimezoneOffset()) * 60 * 1000);
    var oneDay = 1000 * 60 * 60 * 24;
    var day = "00" + Math.floor(d / oneDay);
    return day.substr(-3);
  }

  var targetUrl;

  $("#datepicker")
    .datepicker({
      dateFormat: 'dd-mm-yy',
      onSelect: function(dateText) {
      datePicked = $.datepicker.parseDate('dd-mm-yy', dateText);
       dayPicked = getDayOfYear(datePicked);
       targetUrl  =  "https://datpicker.com/" + dayPicked;
        $(this).change();
      }
    })
    .change(function() {
      alert("Redirect to " + targetUrl);
      //window.location.href = targetUrl;
    });
});
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

window.open('https://www.abdo-host.com', '_blank');

or

  var link = document.createElement("a");
  link.href = 'https://www.abdo-host.com';
  link.target = '_blank';
  var event = new MouseEvent('click', {
      'view': window,
      'bubbles': false,
      'cancelable': true
  });
  link.dispatchEvent(event);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda