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

129
Views
How do I acces a variable in html from a javascript file

Hi I am working on a project and am using express and socketio to construct a website. When I get to index.ejs I get a variable called LocalName that I wish to use in a javascript file linked to index.ejs.

This code is used when creating the variable:

app.get('/', checkAuthenticated, (req, res) => {
    res.render('index.ejs', { LocalName: req.user.name })
})

This is what I wish to do with the variable:

const messageInput = document.getElementById('message-input')
const message = string(LocalName) + ": " + string(messageInput.value)

I have tried using getelementbyBLANK but it does not work.

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!