Dynamic http://community.csdn.net/Expert/topic/3722/3722373.xml?temp=.6881372
<tr><td><input Type=button value= ' < ' name=lefts onclick= "leftimg ();" ></td>
<%set rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT Top 3 * FROM table ORDER BY id DESC", conn,1,1
Ii=1
Do as not rs.eof%>
<td> ' id= ' img<%=ii%> ' ><br><div id= ' txt<%=ii%> ' > <%=rs ("title")%></div></td>
<%ii=ii+1
Rs.movenext
Loop
Rs.close
Set rs=nothing
%>
<td><input Type=button value= ' > ' name=rights onclick= "rightimg ();" ></td>
</tr>
<script>
var imgarray=new Array ();
var txtarray=new Array ();
var ipos=0;
<%set rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT Top 5 * FROM table ORDER BY id DESC", conn,1,1
Ii=0
Do as not rs.eof%>
imgarray[<%=ii%>]= "<%=rs (" img ")%>";
Txtarray[<%=ii%>]= "<%=rs" ("title")%> ";
<%
Ii=ii+1
Rs.movenext
Loop
Rs.close
Set rs=nothing%>
function leftimg () {
ipos++;
Ipos2=ipos;
if (ipos2>4) {ipos2=0;ipos=0}
IMG1.SRC=IMGARRAY[IPOS2];
TXT1.INNERHTML=TXTARRAY[IPOS2];
ipos2++;
if (ipos2>4) {ipos2=0}
IMG2.SRC=IMGARRAY[IPOS2]
TXT2.INNERHTML=TXTARRAY[IPOS2];
ipos2++;
if (ipos2>4) {ipos2=0}
IMG3.SRC=IMGARRAY[IPOS2]
TXT3.INNERHTML=TXTARRAY[IPOS2];
}
function rightimg () {
ipos--;
Ipos2=ipos;
if (ipos2<0) {ipos2=4;ipos=4}
IMG1.SRC=IMGARRAY[IPOS2]
TXT1.INNERHTML=TXTARRAY[IPOS2];
ipos2++;
if (ipos2>4) {ipos2=0}
IMG2.SRC=IMGARRAY[IPOS2]
TXT2.INNERHTML=TXTARRAY[IPOS2];
ipos2++;
if (ipos2>4) {ipos2=0}
IMG3.SRC=IMGARRAY[IPOS2]
TXT3.INNERHTML=TXTARRAY[IPOS2];
}
</script>