Click here to Skip to main content
15,903,523 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have one page (select.php) and I need a div to be shown or hidden on the other page (output.php) when I press a button (in select.php) but without loading any of the two pages.

(to understand it better: both pages are open at the same time (in differents browsers but same machine), in the page select.php i select what output rule i need to show and in the page output.php that information is displayed, the problem is that one of rules is a table with autoscroll so I can't reload the page every second because all the information in the table is not displayed. I have tried the following code but it doesn't work for me because of what I said before:

What I have tried:

output.php
HTML
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>


<div id="reload"></div>

<script>

$(document).ready(function() {
      var refreshId =  setInterval( function(){
    $('#reload').load('includes/outputsetup.php');
  }, 1000 );
});

</script>
</body>

</html>

outputsetup.php
PHP
<?php
$conectar = mysqli_connect("localhost", "root", "", "ianseo");

$sqlend = "SELECT output, oldout FROM tvoutput";
$resultend = mysqli_query($conectar,$sqlend);

while($mostrar=mysqli_fetch_array($resultend)){
$out1 = $mostrar['output'];
$out2 = $mostrar['oldout'];
}


if ($out1==1) {
  include '../finales/scoreboard.php';
}
if ($out1==2) {
  include '../finales/parquero1.php';
}
if ($out1==3) {
  include '../finales/parquero2.php';
}
if ($out1==4) {
  include '../finales/brackets.php';
}
?>

select.php
In this page i have a form with which I send to the database what I want to show
Posted
Updated 11-Jun-20 5:52am
Comments
F-ES Sitecore 11-Jun-20 11:03am    
It will probably depend on how you open the pages in browsers and if there is anything common to the browser sessions that you can leverage like a logged in user. If you are linking to one page from another you can supply a target name and reference the document in the second window by that name;

<a href="..." target="mySecondPage">

1 solution

If you've got something in two browser tabs, they do not know about each other. The server doesn't know about them either. They may as well be one tab on earth and the other tab on the moon.

Once the server send the rendered HTML to the browser, it forgets the request was even made. There is no connection between the page and the server. HTTP works as a request/response system. The browser asks for a page and the server sends it back and moves on to the next request.

So, you have to setup some kind of system where a page, once loaded by the browser, registers for some kind of notification from a separate server and can receive notifications of updates and respond appropriately. You can use something like SignalR to do this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900