Estou com problema para fazer uma consulta em .txt, como não consegui resolver vou postar o codigo que consegui fazer a partir de exemplos que vi e que funciona para ver se alguem pode me dar uma ajuda na modificação para que atenda a minha necessidade. Sou muito iniciante no uso do java.
fotos = [] ;
texto = [];
url = [];
i = 0 ;
fotos[0] = 'fotos/01.jpg' ;
texto[0] = 'ACISE' ;
url[0] = 'fade.html' ;
fotos[1] = 'fotos/02.jpg';
texto[1] = 'Noticia 02' ;
url[1] = 'teste1.html' ;
fotos[2] = 'fotos/03.jpg';
texto[2] = 'Noticia 03' ;
url[2] = 'teste1.html' ;
fotos[3] = 'fotos/01.jpg' ;
texto[3] = 'Noticia 04' ;
url[3] = 'teste1.html' ;
fotos[4] = 'fotos/02.jpg';
texto[4] = 'Noticia 05' ;
url[4] = 'teste1.html' ;
fotos[5] = 'fotos/01.jpg' ;
texto[5] = 'Noticia 06' ;
url[5] = 'teste1.html' ;
fotos[6] = 'fotos/02.jpg';
texto[6] = 'Noticia 07' ;
url[6] = '404.html' ;
fotos[7] = 'fotos/03.jpg';
texto[7] = 'Noticia 08' ;
url[7] = 'teste1.html' ;
fotos[8] = 'fotos/01.jpg' ;
texto[8] = 'Noticia 09' ;
url[8] = 'teste1.html' ;
fotos[9] = 'fotos/02.jpg';
texto[9] = 'Noticia 10' ;
url[9] = 'teste1.html' ;
fotos[10] = 'não-usa';
texto[10] = 'não usa' ;
url[10] = 'teste1.html' ;
function next() {
if ( (i+1) < fotos.length ) show( i+1 ) ;
if ( i == 10 ) show( 0 ) ;
}
function prev() {
if ( i > 0 ) show( i-1 ) ;
}
function show( n ) {
i = n ;
document.getElementById("foto").src = fotos[i] ;
document.getElementById("legenda").innerHTML = '<p>' + texto[i] + ' clique aqui</p>' ;
document.getElementById("contador").innerHTML = '<p>Noticia ' + (n+1) + ' de 10 </p>' ;
}
function goURL(){
window.open(url[i],"noticia","width=450,height=500,scrollbars=NO");
}
o trecho “document.getElementById(“legenda”).innerHTML = ‘
’ + texto[i] + ’ clique aqui
’ ;” faz a colsulta do dado em “texto[dado]” que fica listado entre foto[] e url[]. O que quero é que essa consulta seja feita à um arquivo tipo “dados.txt”. Dai não estou acertando o codigo para que este arquivo .js deve conter para consultar no dados.txt e nem como os dados devem ficar organizados no .txtse alguem puder ajudar… massa, agradeço muito!