Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

283
Vistas
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 Respuestas
Responde la pregunta

0

app.get("/", (req, res) => {
    return res.render("index",
        {
            srcAttr: 'link to image'
        }
    );
});
<img src="<%= srcAttr %>">
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda