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

279
Views
set attribute 'src' to an element in html using nodejs

I use 'express' nodejs and using this code to send url into text

<form method="GET" action='/download' class="my-5">
            <div class="form-group">
                <label for="exampleInputEmail1"
                    >Link:</label
                >
                <input
                    type="text"
                    class="form-control"
                    placeholder="Enter URL"
                    name="url"
                />
            </div>
            <button type="submit" class="btn btn-primary">Download</button>
        </form>

in my project I receive

    const express = require("express");
const app = express();
app.set('view engine', 'ejs');

app.get("/", (req, res) => {
    return res.render("index");
});
app.get("/download", async(req, res) => {
    console.log(req.query.url);
});


app.listen(3000, () => {
    console.log("Server is running on http://localhost:3000");
});

as you can see I use get '/download' to receive url from input and doing some analazing to output new url

my quation is : how can I set this new url to an arttibute 'src' for element (such as img) in homepage without loading new page?

I need only put this new url to be value in 'src' for img in index.eje

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

app.get("/", (req, res) => {
    return res.render("index",
        {
            srcAttr: 'link to image'
        }
    );
});
<img src="<%= srcAttr %>">
over 4 years ago · Santiago Trujillo 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!