PHP use onclick to perform function of another page

0

I have the following link in a header (header.php):

<a href="./index.php" id="btnMinhasReservas2" onclick="irParaMinhasReservas()" class="ph00_9"></a>

The idea is, when I click on this link, go to the index page and execute a function called abreAba() . Will I have to set something up in the index.js file?

    
asked by anonymous 20.01.2015 / 14:28

1 answer

1

The answer is a little gambi, but it can give you a light to improve.

Pass a parameter in the url telling the script to execute the function:

<a href="./index.php?acao=AbreAba" id="btnMinhasReservas2" onclick="irParaMinhasReservas()" class="ph00_9"></a>

In your php file you take this action and execute it:

<?php

if (isset($_GET['AbreAba']) && $_GET['AbreAba'] != '') {
  abreAba();
}

This is not one of the best ways to do it, but it can give you a light to improve your logic there in that part.

    
20.01.2015 / 14:34