PHP and javascript - Running onclick function properly

Asked

Viewed 328 times

2

Hi, I’m a one-page developer for a client. Inside this page, I put a link in the header (header.php file) inside the DIV structure that is like this:

<div onclick="irParaMinhasReservas();" style="cursor: pointer;" id="btnMinhasReservas2" class="ph00_9"></div>

By suggestion in another forum, I defined the function irParaMinhasReservas() so in the main file.js:

function irParaMinhasReservas(){
location.href = 'index.php?param=1'; }

That is, when I have the param variable set, it should go to the index.php page and automatically open a tab that exists inside. The beginning of the index.php page looked like this:

<?php
session_start("usuario");
if(isset($_GET['param'])){
    echo "<script>abreAba(2,logado);</script>";
}?>

But for now I could not make it work. What I may have done wrong or may have forgotten in the codes I defined?

I thank anyone who can help me.

  • as I could not understand exactly where the Error is, and you did not put additional information about your pages and scripts, try to replace the abreAba(2,logado) for window.addEventListener('DOMContentLoaded', function () { abreAba(2,logado); }, false)

  • You need to add more code and explain the functionality you want, otherwise we won’t be able to help. What do you want to do when you open the page index.php? where is the function abreAba? and what has the rest of the index.php?

  • The function abreAba is set in the index.js file and serves to open the tabs that have on the index page.php The error at first is that the way I defined it only shows me the page header by clicking on this link and without the rest of the index page.

  • You have to show more code to understand what each file has...

  • Tobymosque’s suggestion worked. I’m sorry, but I’m afraid for my client if I reveal too many page codes. Anyway, thanks for your help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.