Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 596377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:09:56+00:00 2026-05-13T16:09:56+00:00

I have been trying for a while now trying to figure out how to

  • 0

I have been trying for a while now trying to figure out how to programmatically click a link using PHP and/or javascript. I have it setup so if the user clicks a link it will refresh a table. You don’t really need to know why I want to do this b/c then it will go down a whole long road of confusion. Just know that there is a link to be clicked and I really really want to programmatically click that link using PHP and/or javascript.

Is there really no way to do this?

Edit: The code where I need to put the auto-click is in PHP, which would have to create and trigger some javascript or jquery or whatever.

Edit 2: Ok, now that you’re all confused … the real problem is that I have a Drupal form that has a property set to use AJAX when submitting. So the submission is done using the jquery plugin that is a module for Drupal. The AJAX setting is just an attribute setting and I do not have access to the underlying code that goes along with the submission of the form. Which forces me to have to refresh the table after the button is clicked. I really wish I could just attach the refreshing to the button click event for the submit of the form. But since I don’t have access to that code I don’t believe it’s possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:09:56+00:00Added an answer on May 13, 2026 at 4:09 pm

    With Javascript, you can since it runs on the client machine, where the link exists. But the link doesn’t even exist when PHP is doing it’s magic, so you cannot click it “with” PHP. Keep in mind that PHP runs on the server, but the link exists only on the client.

    Click a link with Javascript is rather simple:

    // <a href="index.php" id="mylink">Index Page</a>
    document.getElementById("mylink").click();
    

    Make sure all of your values are spelled properly. You can even output this command from PHP:

        <?php print "<script type='text/javascript'>
                       document.getElementById('myLink').click();
                     </script>"; ?>
      </body>
    </html>
    

    Note I placed this just before the closing </body> tag to ensure the link is present on the page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to figure this out for a little while now and
I have been trying to get this code to work for a while now
I have been trying to wrap my head around this for a while now
I have been trying to figure out how to do this and it seems
for the last hour I have been trying to figure this out myself but
I have been trying to learn Python for a while now. By chance, I
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,
I have been trying to get around this error for a day now and
I have been trying to make a case for using Python at my work.
I have been trying this one tonight for a while.... I have a UIActionSheet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.