These are chat archives for chat-rooms/programming

23rd
Sep 2017
janvleugels
@janvleugels
Sep 23 2017 13:22
Hi! anyone hes knowledge of php / laravel?
AnaCamelo
@AnaCamelo
Sep 23 2017 20:19
@AnaCamelo
Hello! Sorry. I have a question and I was wondering if anyone could help me
I have this line of code: slides[i].style.display = "none";
but, i don't understand what the slides[i] means
Could anyone explain me ? Thanks!
VoidVolker
@VoidVolker
Sep 23 2017 20:20
slides - is array, and i is index
for eaxmple: slides = [slideOne, slideTwo, slideThree]
AnaCamelo
@AnaCamelo
Sep 23 2017 20:28
So, here:
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
it is saying to hide ALL the slides? what about the one that is being displayed?
it is a bit confusing to me. Thank you for answering @VoidVolker :)
VoidVolker
@VoidVolker
Sep 23 2017 20:29
yes. correct, this will hide all slides
also, it is better to cache slides.length to separate variable
AnaCamelo
@AnaCamelo
Sep 23 2017 20:29
so, how is that one of the slides is being showed?
VoidVolker
@VoidVolker
Sep 23 2017 20:30
add code to show selected slide?
AnaCamelo
@AnaCamelo
Sep 23 2017 20:31
well, the code is working great, but i don't understand why if that loop is hiding all the slides, how is one being displayed?
VoidVolker
@VoidVolker
Sep 23 2017 20:31
in this loop no one slide is being displayed
AnaCamelo
@AnaCamelo
Sep 23 2017 20:31
exactly, that's why I'm confused
VoidVolker
@VoidVolker
Sep 23 2017 20:32
check other code
AnaCamelo
@AnaCamelo
Sep 23 2017 20:32
Can i show you athe whole code?
VoidVolker
@VoidVolker
Sep 23 2017 20:32
this loop isnt the place for searching the displayed slide
use ``` for code
before and after
AnaCamelo
@AnaCamelo
Sep 23 2017 20:33
oohh ok, thanks! :)

' var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
showSlides(slideIndex += n);
}

function currentSlide(n) {
showSlides(slideIndex = n);
}

function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
}'

single quotation mark for the code? it didn't seem to work
VoidVolker
@VoidVolker
Sep 23 2017 20:34
wrooong style! use ``` for code wrapping
not single quotation, three apostrophe
AnaCamelo
@AnaCamelo
Sep 23 2017 20:35
k
VoidVolker
@VoidVolker
Sep 23 2017 20:36
@AnaCamelo edit your msg for correct style
@AnaCamelo you can edit your msg, please don't flood
AnaCamelo
@AnaCamelo
Sep 23 2017 20:38
sorry, I'm trying
VoidVolker
@VoidVolker
Sep 23 2017 20:38
code isn't redable, fix style before for more redaible view
AnaCamelo
@AnaCamelo
Sep 23 2017 20:38
ok
VoidVolker
@VoidVolker
Sep 23 2017 20:39
var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
    showSlides(slideIndex += n);
}

function currentSlide(n) {
    showSlides(slideIndex = n);
}

function showSlides(n) {

    var i;    
    var slides = document.getElementsByClassName("mySlides");
    var dots = document.getElementsByClassName("dot");

    if (n > slides.length) {slideIndex = 1}
    if (n < 1) {slideIndex = slides.length}

    for (i = 0; i < slides.length; i++) {
        slides[i].style.display = "none";
    }

    for (i = 0; i < dots.length; i++) {
        dots[i].className = dots[i].className.replace(" active", "");
    }

    slides[slideIndex-1].style.display = "block";
    dots[slideIndex-1].className += " active";
}
AnaCamelo
@AnaCamelo
Sep 23 2017 20:40
I can't make it work :S
VoidVolker
@VoidVolker
Sep 23 2017 20:40
like this
new line after ```
AnaCamelo
@AnaCamelo
Sep 23 2017 20:41
var slideIndex = 1;
showSlides(slideIndex);

function plusSlides(n) {
  showSlides(slideIndex += n);
}

function currentSlide(n) {
  showSlides(slideIndex = n);
}

function showSlides(n) {
  var i;
  var slides = document.getElementsByClassName("mySlides");
  var dots = document.getElementsByClassName("dot");
  if (n > slides.length) {slideIndex = 1} 
  if (n < 1) {slideIndex = slides.length}
  for (i = 0; i < slides.length; i++) {
      slides[i].style.display = "none"; 
  }
  for (i = 0; i < dots.length; i++) {
      dots[i].className = dots[i].className.replace(" active", "");
  }
  slides[slideIndex-1].style.display = "block"; 
  dots[slideIndex-1].className += " active";
}
there you go! :)
thank you!
VoidVolker
@VoidVolker
Sep 23 2017 20:42
cool ) grac :+1:
check the string slides[slideIndex-1].style.display = "block";
@AnaCamelo
this is what you are lokking for
AnaCamelo
@AnaCamelo
Sep 23 2017 20:44
The script i have is working well, i just want to understand it
VoidVolker
@VoidVolker
Sep 23 2017 20:45
goog, so, this string is show current slide
AnaCamelo
@AnaCamelo
Sep 23 2017 20:51
oohhh ok.. i think i get it
thanks a lot @VoidVolker