C
C
Craken6662021-06-27 23:43:06
HTML
Craken666, 2021-06-27 23:43:06

How to pass data to another page on click?

Tell me how to transfer information to another page when clicked. As far as I understand, I give an id to the element that I need to display, and I also hang an onclick event on it, and in JS I create a function with this event, in the function I create a variable with this element, but how to display it on a separate page and what is responsible for this?

one.

Add an ID and create an event
foreach ($result_set as $row) {
  echo 
  '<div class="videoStyle">
  <span class="videoName">    
  <a href=" '.$directory.'/'.$row['video_name'].'""><video method="GET" onclick="openWatchVideo()" id="video-player" data-playerVideo = "'.$row['id'].'" width="100%" height="100%" src="'.$directory.'/'.$row['video_name'].'">'.$row['title'].'</video><br><span>'.$row['title'].'</span></a>
  </span>
  </div>';
  $i++; 
  }
60d8e118c54ed166457117.png


2.
Accessing an element in JS
function openWatchVideo(){
  let videoPlayerId = document.getElementById('video-player'); 
}
60d8e18c7630d915751680.png

What needs to be added further to bring it to the page with point 3? And what is responsible for displaying elements on another page?

3.
What needs to be added in JS so that the video is displayed when opened on this page?
60d8e1ecb366a030031073.png


Tell me what to read, or what information to look for? And also if you know what code to add please tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
ThunderCat, 2021-06-28
@ThunderCat

First of all, tags - what does html have to do with it? Do you have a problem in zhs and php?
Secondly, output elements in a loop, which implies that there are several of them, while they all have the same id, you can’t do this.

Tell me how to transfer information to another page when clicked.
There are many ways, get parameter, cookies, session ... In each case, a more acceptable option is suitable. Instead of letting in the fog, formulate the task more clearly, according to your description, it's not clear what you want to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question