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

115
Views
how to make a getElementById value available for another page

I have a form that has two input fileds, I want the value entered in the first page to be available when redirected to another route?

I have an '/instances' route which renders an 'instances' view, this 'instances' view has two input text which ids are 'Instances' and 'Region' and a button id = 'runScriptButton' that has onclick = "launchTerraform()"

once the button is clicked it executes the launchTerraform() and redirects the user to the '/dashboard' route, in this route there is a button as well with id = 'destroyButton'. in this '/dashboard' route, I would like to have access to the input values entered by the user in the '/instances' page.

Here is what I have tried so far, but It does not work, once on '/dashboard', 'data' is not accessible.

function launchTerraform() {
  // this is the data I would like to be able access from /dashboard route
  var data = {
    instances: document.getElementById('Instances').value,
    region: document.getElementById('Region').value
  }
   
  if (document.getElementById('runScriptButton') ){

    var xhr = new window.XMLHttpRequest()
    xhr.onreadystatechange = function () {
    if (this.readyState === 4 && this.status === 200 ) {
      window.location.href = '/dashboard'
    }
  }
  document.getElementById("test").textContent = "Please wait ...";
  xhr.open('POST', '/provision', true)
  xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
  xhr.send(JSON.stringify(data))
}

   if (document.getElementById('destroyButton')){
    var xhr = new window.XMLHttpRequest()
    xhr.onreadystatechange = function () {
    if (this.readyState === 4 && this.status === 200 ) {
      document.getElementById("divDestoyResources").textContent = "Resources Deleted"
    }
  }
  document.getElementById("divDestoyResources").textContent = "Please wait while resources are released ...";
  xhr.open('POST', '/destroy', true)
  xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8')
  xhr.send(JSON.stringify(storeData))
}
   
}
about 4 years ago · Juan Pablo Isaza
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!