Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!