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

185
Vistas
Pass variable from function js to other function js

I'm trying to pass and hold the value of store so that everytime user selects a different day, the value of store remains the same.

store and day chart

At first, I managed to show the result when I chose the store and the day values. However, when I changed to a different day, it doesn't hold the store value.

function changestore(){
      var filterstoregen = document.getElementById("filterstoregen").value;
      return filterstoregen;
      window.location.href='/new-retail/visitorreport?storename_='+filterstoregen;
 }


function changeday(){
      var storename2 = changestore();
      var filterday = document.getElementById("filterday").value;
      window.location.href='/new-retail/visitorreport?storename_='+storename2+'&dayname='+filterday;
 }

If I want to see the results of a different day, I need to choose again the store value first. This is because the chart becomes blank as if the store value is not selected.

Note that the functions written in the same file which is visitorreport.php.

Hopefully I have provided enough information to get some help. Thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Rather than rebuilding the URL from scratch, you could take the page's current URL and only modify the parameter that was updated in the dropdown.

function changestore(){
      var filterstoregen = document.getElementById("filterstoregen").value;
      let params = (new URL(window.location)).searchParams;
      params.set('storename', filterstoregen);
      window.location.search = params.toString();
 }


function changeday(){
      var filterday = document.getElementById("filterday").value;
      let params = (new URL(window.location)).searchParams;
      params.set('dayname', filterday);
      window.location.search = params.toString();
 }
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