案例三:
原参数调用部分:
<script language=javascript type=text/javascript>
var picarry = {};
var lnkarry = {};
var ttlarry = {};
picarry[0] = "http://www.url.com/01.jpg";
lnkarry[0] = "http://www.url.com/1.html";
ttlarry[0] = "标题一";
picarry[1] = "http://www.url.com/02.jpg";
lnkarry[1] = "http://www.url.com/2.html";
ttlarry[1] = "标题二";
picarry[2] = "http://www.url.com/03.jpg";
lnkarry[2] = "http://www.url.com/3.html";
ttlarry[2] = "标题三";
picarry[3] = "http://www.url.com/04.jpg";
lnkarry[3] = "http://www.url.com/4.html";
ttlarry[3] = "标题四";
picarry[4] = "http://www.url.com/05.jpg";
lnkarry[4] = "http://www.url.com/5.html";
ttlarry[4] = "标题五";
</script>
这其实很简单,跟案例一一样的道理,只不过多了个序号,那我们就用{$AutoID}这个函数吧,循环体如下:
<script language=javascript type=text/javascript>
var picarry = {};
var lnkarry = {};
var ttlarry = {};
[loop=5]
picarry[{$AutoID}] = "{$Field(PicUrl,Text,0,...,0,)} ";
lnkarry[{$AutoID}] = "{$Field(id,getinfourl,1,1,)} ";
ttlarry[{$AutoID}] = "{$Field(title,Text,0,...,0,)} ";
[/loop]
</script>
又有个问题,{$AutoID}无法输出小于1的序数,我们把循环体改成如下便可轻松解决:
<script language=javascript type=text/javascript>
var picarry = {};
var lnkarry = {};
var ttlarry = {};
[loop=1]
picarry[0] = "{$Field(PicUrl,Text,0,...,0,)} ";
lnkarry[0] = "{$Field(id,getinfourl,1,1,)} ";
ttlarry[0] = "{$Field(title,Text,0,...,0,)} ";
[/loop]
[loop=4]
picarry[{$AutoID}] = "{$Field(PicUrl,Text,0,...,0,)} ";
lnkarry[{$AutoID}] = "{$Field(id,getinfourl,1,1,)} ";
ttlarry[{$AutoID}] = "{$Field(title,Text,0,...,0,)} ";
[/loop]</script>
同样的,举一些例子:
这种SQL效果 我在后台也是如此设置的,为什么在前台输出为空呢?特别是[loop=4]、picarry[{$AutoID}] = "{$Field(PicUrl,Text,0,...,0,)} ";等等都不好用