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

213
Vistas
trigger a button after clicking another button from another page with javascript or jquery

I have 3 buttons on the “home.php” page, and when I make click in any of them, these 3 buttons redirect to a same page (“create.php” page) but each one of them automatically triggers its corresponding button in the new redirected page (“create.php” page)

e.g => button 1 (id="buttonHome1") from home.php page redirects to create.php page and triggers the button 1 (id="buttonCreate1") that is in create.php page

Button 1

<a href="create?car=1">
<button id="buttonHome1">Button 1</button>
</a>

Button 2

<a href="create?bike=1">
    <button id="buttonHome2">Button 2</button>
</a>

Button 3

<a href="create?bike=1">
<button id="buttonHome3">Button 3</button>
</a>

In my .js file I got this

var url = window.location.href;
 
window.onload = function () {
    var link = url.split("?car=");
    if (link.length > 1) {
        $("#buttonCreate1").click();
    }
}

This javascript (jquery) code is running fine, but just for one button, what I mean is: I f I use the same window.onload function for the button2 , run ok but override the first button, the same happens if is used for third button, overrides the other 2 buttons

I would like all buttons working but I don't know at the moment how to handle this.

I tried also with

$("#buttonHome1").click(function(){
    $("buttonCreate1").click(); 
    return false;
});
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Have you tried addEventListener?

You can have multiple listeners like that

window.addEventListener('load', function(){
  // Do your stuff here
});

window.addEventListener('load', function(){
  // Another one
});

https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event

about 4 years ago · Juan Pablo Isaza 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