Boa Noite Pessoal!
Estou com um pequeno problema…
Estou com um sisteminha em java que resgata noticias em um banco de dados e exibe cada registro dentro de um Array… Cada item desse array é exibido sequencialmente com recursos de Fade In e Fade Out…
Todavia, o problema é que quando removo um registro do database, o mesmo continua sendo procurado pelo Java…
Além disso gostaria que ele fizesse a leitura de forma decrescente… para que as noticias mais recentes fossem exibidas primeiro…
Exemplo no site: http://www.vjmi.com.br/2009/Noticias.asp
Exemplo:
fcontent[0] = “noticia 1”
fcontent[1] = “noticia 2”
fcontent[2] = “noticia 3”
fcontent[3] = “noticia 4”
Acontece que estou gerando os itens do array de acordo com os registro do banco…
fcontent[<%=nt2(“id”)%>]=“conteudo”;
Aí quando removo um registro o java procura a sequencia…
Eu gostaria de saber se tem como ele ignorar a leitura de um item dentro do array quando ele inexiste?
Olha meu código como está…
<!-- #include file="config.inc" --><%session.LCID=1046%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>VJ | MCE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #F2F2F2;
}
-->
</style>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" marginwidth="0">
<a target="_parent"><img /></a>
<script type="text/javascript">
/***********************************************
* Fading Scroller- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var delay = 3500; //set delay between message change (in miliseconds)
var maxsteps=30; // number of steps to take to change from start color to endcolor
var stepdelay=40; // time in miliseconds of a single step
//**Note: maxsteps*stepdelay will be total time in miliseconds of fading effect
var startcolor= new Array(255,255,255); // start color (red, green, blue)
var endcolor=new Array(221,91,94); // end color (red, green, blue)
var fcontent=new Array();
begintag='<div style="font: normal 12px trebuchet MS; padding: 15px;">'; //set opening tag, such as font declarations
<%
Set nt2 = Server.CreateObject("ADODB.Recordset")
nt2.Open "SELECT * FROM noticias ORDER BY id ASC", DB
Do while not nt2.Eof
Titulo = nt2("titulo")
Chamada = nt2("chamada")
Data = nt2.fields("data")
Dim dbX2
if dbX2 <> currdate then
dbX2 = currdate
Session.LCID = 1046
end if
%>
fcontent[<%=nt2("id")%>]="<a target='_parent' ><%Response.Write Titulo%></a><br><br><%Response.Write Chamada%><br><br><span class='datas'>[<%Response.Write Data%>]</span>";
<%
nt2.Movenext
Loop
%>
closetag='</div>';
var fwidth='250px'; //set scroller width
var fheight='150px'; //set scroller height
var fadelinks=1; //should links inside scroller content also fade like text? 0 for no, 1 for yes.
///No need to edit below this line/////////////////
var ie4=document.all&&!document.getElementById;
var DOM2=document.getElementById;
var faderdelay=0;
var index=1;
/*Rafael Raposo edited function*/
//function to change content
function changecontent(){
if (index>=fcontent.length)
index=1
if (DOM2){
document.getElementById("fscroller").style.color="rgb("+startcolor[0]+", "+startcolor[1]+", "+startcolor[2]+")"
document.getElementById("fscroller").innerHTML=begintag+fcontent[index]+closetag
if (fadelinks)
linkcolorchange(1);
colorfade(1, 15);
}
else if (ie4)
document.all.fscroller.innerHTML=begintag+fcontent[index]+closetag;
index++
}
// colorfade() partially by Marcio Galli for Netscape Communications. ////////////
// Modified by Dynamicdrive.com
function linkcolorchange(step){
var obj=document.getElementById("fscroller").getElementsByTagName("A");
if (obj.length>0){
for (i=0;i<obj.length;i++)
obj[i].style.color=getstepcolor(step);
}
}
/*Rafael Raposo edited function*/
var fadecounter;
function colorfade(step) {
if(step><=maxsteps) {
document.getElementById("fscroller").style.color=getstepcolor(step);
if (fadelinks)
linkcolorchange(step);
step++;
fadecounter=setTimeout("colorfade("+step+")",stepdelay);
}else{
clearTimeout(fadecounter);
document.getElementById("fscroller").style.color="rgb("+endcolor[0]+", "+endcolor[1]+", "+endcolor[2]+")";
setTimeout("changecontent()", delay);
}
}
/*Rafael Raposo's new function*/
function getstepcolor(step) {
var diff
var newcolor=new Array(3);
for(var i=0;i<3;i++) {
diff = (startcolor[i]-endcolor[i]);
if(diff > 0) {
newcolor[i] = startcolor[i]-(Math.round((diff/maxsteps))*step);
} else {
newcolor[i] = startcolor[i]+(Math.round((Math.abs(diff)/maxsteps))*step);
}
}
return ("rgb(" + newcolor[0] + ", " + newcolor[1] + ", " + newcolor[2] + ")");
}
if (ie4||DOM2)
document.write('<div id="fscroller" style="width:'+fwidth+';height:'+fheight+'"></div>');
if (window.addEventListener)
window.addEventListener("load", changecontent, false)
else if (window.attachEvent)
window.attachEvent("onload", changecontent)
else if (document.getElementById)
window.onload=changecontent
</script>
<div id="fscroller" style="width: 250px; height: 150px; color: rgb(221,91,94);"></div>
</body>
</html>