Select Correct Video Source from Select Dropdown List
Hi Friends,
I've been stuck on a problem for days and I am hoping someone can shed some light on it. I have a script where any user can select an employee from a dropdown list and it will display the employee's information and image. Those functions work perfectly but I now have a requirement to add a video and I cannot get my script to select a user's video. It is only selecting the last employee in the database, i.e., the one with the highest id. I can change a few words in the below script to display images instead of videos and it grabs the correct employee image each time. Below is the portion of the script where I am stuck. Any advice is greatly appreciated!
<!-- PATH TO JQUERY -->
<script type="text/javascript" src="jquery.js"></script>
<!-- SELECT SCRIPT -->
<script type="text/javascript">
$(function(){
$('#selection_name').change(function() {
var videoFile = '<?php echo $row['user_video_path']; ?>';
$('#selection_name video source').attr('src', videoFile);
$('#selection_name video')[0].load();
});
});
</script>
<!-- SELECT USER ALONG WITH THEIR VIDEO -->
<select id="selection_name" onchange="getId(this.value);">
<option value="">Select Video to Display</option>
<?php
$query = "SELECT * FROM user_tbl";
$results = mysqli_query($con, $query);
foreach ($result as $row) { ?>
data-user_video_path="<?php echo !empty($row['user_video_path']) ? ($row['user_video_path']) : "" ; ?> "
<option echo value="<?php echo $row['user_video_path']; ?> ">
<?php echo $row['user_first_name'], " " ,$row['user_last_name']; ?>
</option>
<?php
}
?>
</select>
<!-- DISPLAY VIDEO FOR SELECTED USER -->
<div id="selection_name">
<video controls="true" autoplay="true" poster="images/blank.jpg">
<source src="user_video_path" name="user_video_path"></source>
</video>
</div>
Subject
Written By
Posted
Select Correct Video Source from Select Dropdown List
November 17, 2017 01:57PM
November 17, 2017 04:09PM
November 19, 2017 04:51PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.