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

210
Views
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 answers
Answer question

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 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!