SérgioSantos Posted August 3, 2014 at 01:29 PM Report Share #563928 Posted August 3, 2014 at 01:29 PM Bom dia pessoal do P@P. Estou com umas dúvidas numa coisa que pretendo fazer e venho vos pedir uma ajudinha. Basicamente queria criar uma tabela que contém 5 imagens oriundas da minha base de dados mysql. Até aqui tudo bem, mas eu pretendia adicionar a essa tabela um botão de next e prev. Ou seja andar para trás e para frente sem fazer reload à página. Será que existe algum script em javascript ou até mesmo em ajax que me permite fazer isto sem fazer reload à pagina? Link to comment Share on other sites More sharing options...
KTachyon Posted August 3, 2014 at 01:48 PM Report Share #563929 Posted August 3, 2014 at 01:48 PM Carregas todas as imagens: var images = []; for (var i = 0; i < imageCount; i++) { var image = new Image(); image.src = "path/to/image_" + i + ".png"; images.push(image); } Depois só precisas de ter uma variável para representar a imagem que está a ser apresentada actualmente e controlar essa variável no clique dos botões. Para apresentares a imagem só tens que colocar o elemento no DOM. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now