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

172
Views
How to input a variable for the p id = "variable"

I have the following code

<span id="X1a">

<script>

document.getElementById("X1").innerHTML = 'Output1'
document.getElementById("X2").innerHTML = 'Output2'

<!---etc - several more similar lines for Outputx-->


</script>

What I want to do is to be able to input (or select) the value to put in the id= line. So i can choose to print X1 or X2 or Xx. How can I do that?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can use setAttribute() to change the value id. example

document.getElementById("id").setAttribute("id", "X1")

or you can read reference in w3school

https://www.w3schools.com/jsref/met_element_setattribute.asp

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!