Edrol97
Coder
Hi All,
Wondering what's up with my JS. I'm wanting to launch a second lightbox gallery alongside a first and wonder what I've done wrong. I'll attach my HTML and JS below as I'm not sure if either are right.
Wondering what's up with my JS. I'm wanting to launch a second lightbox gallery alongside a first and wonder what I've done wrong. I'll attach my HTML and JS below as I'm not sure if either are right.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Image carousel</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>The Headlines</h1>
<div class="container">
<div class="gallery1">
<img src="img/Slide%20away.png" alt=" "width="300px" height="300px" onclick="LaunchLightbox(1)">
</div>
<div class="gallery2">
<img src="img/Minute Books/Minute Books.png" alt=" "width="300px" height="300px" onclick="LaunchLightbox(2)">
</div>
</div>
<div class="slide-show_container">
<div class="next_button" onclick="NextImage()">⟹</div>
<div class="previous_button" onclick="PreviousImage()">⟸</div>
<div class="close_button" onclick="CloseLightbox()">☒</div>
<div class="image_slide" onclick="slides()"></div>
<div class="image_slide">
<img src="img/BA%20Exhibition%20View.png" width="400px">
<div class="title_text">Politics 24/7?</div>
<div class="caption_text">Come in. Take a seat! Make yourself at home, but something doesn't
feel quite right
</div>
</div>
<div class="image_slide">
<img src="img/Truly%20Brexish%20Summer.jpg" width="400px">
<div class="title_text">A Very Brexish Summer</div>
<div class="caption_text"> A display for the BCX 2019 show at the Bentall Centre. An ironic
party in Brexit's dishonour</div>
</div>
<div class="image_slide">
<img src="img/New%20Contemps%202019.png" width="400px">
<div class="title_text">Boris Can't Get Clean, however much he tries</div>
<div class="caption_text">Into the Gallery at South London Gallery, Leeds Art Gallery and The RA</div>
</div>
<div class="image_slide">
<img src="img/MFA%20Final%20Show%203.jpg" width="400px">
<div class="title_text">Pinocchio is nice at least</div>
<div class="caption_text">A piñata to celebrate the former Prime Minister for what he was best at.
</div>
</div>
<div class="image_slide">
<img src="img/Exhibition%20Left%20Side%20Door%20View.png" width="400px">
<div class="title_text">Party Politics</div>
<div class="caption_text">Welcome to the party. Boris isn't invited</div>
</div>
<div class="image_slide">
<img src="img/Bad%20Times%20logo%20Colourised%20A5.png" width="400px">
<div class="title_text">Bad Times are here</div>
<div class="caption_text">With the media in the state that it's in, it's no wonder</div>
</div>
<div class="image_slide">
<img src="img/Failing%20Everyday%20A5.png" width="400px">
<div class="title_text">Daily Fail</div>
<div class="caption_text">The Daily Mail is a bastion... of real FAKE NEWS</div>
</div>
<div class="image_slide">
<img src="img/Sadly%20Substandard%20A5.png" width="400px">
<div class="title_text">A Very Standard State Of Affairs</div>
<div class="caption_text">Mr Lebedev needs to brush up on the truth</div>
</div>
<div class="image_slide">
<img src="img/A%20Bit%20Of%20A%20Mix%20Up.png" width="400px">
<div class="title_text">Rishi's getting a bit mixed up</div>
<div class="caption_text">Culture wars might not be the godsend that Rishi Sunak thinks it will be</div>
</div>
<div class="image_slide">
<img src="img/Blue%20Sky%20Thinking.png" width="300px">
<div class="title_text">Blue Sky Thinking</div>
<div class="caption_text">Rishi's Stop The Boats tactics don't seem to be working too well</div>
</div>
<div class="image_slide">
<img src="img/Culture%20War%20On%20Woke.png" width="400px">
<div class="title_text">GB News has no culture</div>
<div class="caption_text">The Tories are looking for an election strategy and GB News has come to the rescue
providing them a desperately needed platform. It won't work.</div>
</div>
<div class="image_slide">
<img src="img/Nothing%20to%20see%20here.png" width="400px">
<div class="title_text">What has Rishi got to hide?</div>
<div class="caption_text">They'll be hiding more and more come the election</div>
</div>
<div class="image_slide">
<img src="img/Out%20of%20Tune%20ideas.png" width="400px">
<div class="title_text">A Very Budget Cabinet Karaoke. </div>
<div class="caption_text">No ideas incoming</div>
</div>
<div class="image_slide">
<img src="img/Budget%20Fare.png" width="400px">
<div class="title_text">They've Got A Ticket To Ride</div>
<div class="caption_text">One way ticket to nowhere for the Tories</div>
</div>
<div class="image_slide">
<img src="img/Mayday Maynay!.png" width="400px">
<div class="title_text">Mayday Maynay!</div>
<div class="caption_text">SOS It's over Rishi!</div>
</div>
<div class="image_slide">
<img src="img/That's%20Racist.png" width="500px">
<div class="title_text">Hester Festers</div>
<div class="caption_text">The Frank Hester row wages on, as the Tories are embroiled in a racism row</div>
</div>
<div class="image_slide">
<img src="img/Ofcom%20Offence.png" width="400px">
<div class="title_text">GB Not News</div>
<div class="caption_text">When will the self-appointed Government psychopants learn that lies must be punished?</div>
</div>
<div class="image_slide">
<img src="img/Budget%20Budget.png" width="400px">
<div class="title_text">The Budgetest of all Budgets</div>
<div class="caption_text">This budget won't stretch far</div>
</div>
<div class="image_slide">
<img src="img/Vultures%20Circling.png" width="300px">
<div class="title_text">Very Nearly Dead Meat</div>
<div class="caption_text"></div>
</div>
<div class="image_slide">
<img src="img/Double%20Standards.png" width="400px">
<div class="title_text">Lionising Stupidity</div>
<div class="caption_text">Everyone's going mental over the England kit.</div>
</div>
<div class="image_slide">
<img src="img/Cross Wires.png" width="400px">
<div class="title_text">Cross Wires</div>
<div class="caption_text">Both Russian leadership and ISIS are made up of angry men, but this is
something I didn't predict
</div>
</div>
<div class="image_slide">
<img src="img/Nothing but Kate.png" width="250px">
<div class="title_text">With Apologies to Matt Groening</div>
<div class="caption_text">Princess of Wales Kate has been diagnosed with Cancer. I'm sorry, but millions
are going through what she is going through with far less support. It shouldn't be headline news
</div>
</div>
</div>
<div class="slide-show_2container">
<div class="next_button" onclick="NextImage()">⟹</div>
<div class="previous_button" onclick="PreviousImage()">⟸</div>
<div class="close_button" onclick="CloseLightbox()">☒</div>
<div class="image_slide" onclick="slides()"></div>
<div> <img src="img/Minute Books/Minute Books.png"></div>
<div class="image_slide">
<img src="img/Minute Books/Minute Books 01:2019.png" alt="">
</div>
<div class="image_slide">
<img src="img/Minute Books/Minute Books 15:01.png"></div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
JavaScript:
let slides = document.getElementsByClassName("image_slide");
let counter=1;
let totalimages=22
slides[counter].style.display="block";
function NextImage(){
for (let i=0;i<totalimages+1;i++){
slides[i].style.display="none";
}
counter=counter+1;
if (counter > totalimages){
counter=1;
}
slides[counter].style.display="block";
}
function PreviousImage(){
for (let i=0;i<totalimages+1;i++){
slides[i].style.display="none";
}
counter=counter-1;
if (counter < 1){
counter=totalimages;
}
slides[counter].style.display="block";
}
function LaunchLightbox(num){
if(num==1){
let Lightbox= document.getElementsByClassName("slide-show_container");
Lightbox[0].style.display="block";
}
if(num==2){
let Lightbox= document.getElementsByClassName("slide-show_2container");
Lightbox[0].style.display="block";
}
}
let ImageSlides = document.getElementsByClassName("ImageSlide")
let TotalImages=3
ImageSlides[counter].style.display=block;
function NextImageSlide(){
for (let i=0;i<TotalImages+1;i++){
ImageSlides[i].style.display="none";}
}
counter=counter+1;
if (counter > TotalImages){
counter=1;
}
function Close_Lightbox(){
let Lightbox= document.getElementsByClassName("slide-show_container","slide-show_2container");
Lightbox[0].style.display="none"
}