旋转表格单元格的内容 [英] Rotating content for table cells

查看:76
本文介绍了旋转表格单元格的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个包含2列和20行的表。我想在

表的每个单元格中插入

小图片(每个都有一个链接)和一个文本标题。


刷新页面时,我想让每个单元格的内容随机旋转。


注意文字标题必须保留其相关图片

和链接(我不想加扰所有元素 - 只需旋转

表格单元格的全部内容)。


是否有一个脚本可以实现这一目标?谢谢。

解决方案

" Royal Denning" <为RO *********** @ hotmail.com>在消息中写道

新闻:4e ************************* @ posting.google.co m ... < blockquote class =post_quotes>我正在设计一个包含2列和20行的表。我想在
表的每个单元格中插入
小图片(每个都有一个链接)和一个文本标题。

刷新页面时,我希望有每个单元格的内容
(图片/链接和相关文本)随机旋转。

请注意,文字标题必须保留其相关图片
和链接(我不是''想要扰乱所有元素 - 只需旋转表格单元格的整个内容。

是否有一个脚本可以实现这一目标?谢谢。




也许这会给你一些想法。


测试按原样;请注意自动换行。


< html>

< head>

< title> rotate26.htm< / title>

< script type =" text / javascript">

函数字母(){

var abc =" abcdefghijklmnopqrstuvwxyz" ;;

var now = new Date();

var pos = now.getSeconds()%26;

var let = abc .substr(pos);

if(pos> 0)let + = abc.substring(0,pos);

alert(pos +" \t" ; + let);

var url =" http://205.200.38.172/aagraphics/letters/letter?.jpg" ;;

var src;

var txt = new Array();

var img = new Array();

for(var i = 0; i< let.length; i ++){

src ="< a href =''" + url +"''target =''_ blank''>"

src + ="< img src =''" + url +"''" ;;

src + =" border =''0''width =''109''height ='''83''alt =''?' '>< / a>" ;;

img [i] = src.replace(/\?/g,let.charAt(i));

txt [i] ="< br> The Letter" + let.charAt(i).toUpperCase();

}

var j = 0;

var tab = new Array();

tab [j ++] ="< table border =''0''cellpadding =''0''cellspacing =''0''

width =' '218''>" ;;

var mid = let.length / 2;

for(var k = 0; k< mid; k ++){

tab [j ++] ="< tr height =''100''valign =''top''>" ;;

tab [j ++] =" < th width =''109''>" + img [k] + txt [k] +"< / th>" ;;

tab [j ++] =" < th width =''109''>" + img [k + mid] + txt [k + mid] +

"< / th>" ;;

tab [j ++] ="< / tr>" ;;

}

tab [j ++] ="< / table>" ;;

document.write( tab.join(""));

}

letters();

< / script>

< / head>

< body>

< / body>

< / html>


谢谢,McKirahan。


我还是Javascripting的新手,所以我在哪里进入
单元格,图像,文本和网址的
值?"


" Royal Denning" <为RO *********** @ hotmail.com>在留言中写道

news:4e ************************** @ posting.google.c om ...

谢谢,McKirahan。

我仍然是Javascripting的新手,所以我在哪里输入单元格,图像的
值,文字和网址?"




这应该更清楚一点。


< html>

< head>

< title> rotate10.htm< / title>

< script type =" text / javascript">

函数数字(){

var url =" http://www.scri8e.com/TTF/alphas/redgelharts/" ;;

var gif = new Array();

gif [0] =" 0.gif | Zero";

gif [1] =" 1.gif | One" ;;

gif [2] =" 2.gif | Two";

gif [3] =" 3.gif | Three";

gif [4] =" 4.gif | Four";

gif [5] =" 5.gif | Five";

gif [ 6] =" 6.gif | Six";

gif [7] =" 7.gif | Seven& ;;

gif [8] =" 8.gif | Eight"

gif [9] =" 9.gif | Nine";

for(var i = 0; I< gif.length; i ++){

gif [i] = url + gif [i];

}

var hig = 82;

var wid = 46;

var wyd = wid * 2;

var ten =" 0123456789";

var mod = ten.length;

var now = new Date();

var pos = now.getSeconds()%mod;

var num = ten.substr(pos);

if(pos> 0)num + = ten.substring(0,pos);

var col = new Array();

var src;

var sub;

var tmp;

for(var j = 0; j< num.length; j ++){

sub = num.charAt(j);

tmp = gif [sub] .split(" |");

src ="< a href =''" + tmp [0] +"''target =''_ blank''>"

src + ="< img src =''" + tmp [0] +"''" ;;

src + =" border =''0''width =''" + wid +"''height =''" + hig +"''

alt =''''>< / a>" ;;

src + ="< br>" + tmp [1];

col [j] = src;

}

var k = 0;

var tab = new Array();

tab [k ++] ="< table border =''0''cellpadding =''0''cellspacing =''0''

width =''" + wyd +"''>" ;;

var mid = num.length / 2;

for(var l = 0; l< mid; l ++) {

tab [k ++] ="< tr height =''" + hig +"''valign =''top''>" ;;

tab [k ++] =" < th width =''" + wid +"''>" + col [l] +"< / th>" ;;

tab [k ++] =" < th width =''" + wid +"''>" + col [l + mid] +"< / th>" ;;

tab [k ++] ="< / tr>" ;;

}

tab [k ++] ="< / table>" ;;

document.write(tab.join(""));

}

数字();

< / script>

< / head>

< body>

< / body>

< / html>


修改gif用于标识每个图像的数组,后跟|。然后是

图像的文字。改变wid和高到宽度和高度

的图像。这将处理旋转十个图像;我会把它留给

手柄二十。


I am designing a table with 2 columns and 20 rows. I want to insert
small images (each with a link) and a text title in each cell of the
table.

On refresh of the page, I would like to have the contents of each cell
(picture/link and associated text) rotate randomly.

Note that the text titles must remain with their associated picture
and link (I don''t want to scramble all the elements--just rotate the
entire contents of the table cell).

Is there a script that will accomplish this? Thanks.

解决方案

"Royal Denning" <ro***********@hotmail.com> wrote in message
news:4e*************************@posting.google.co m...

I am designing a table with 2 columns and 20 rows. I want to insert
small images (each with a link) and a text title in each cell of the
table.

On refresh of the page, I would like to have the contents of each cell
(picture/link and associated text) rotate randomly.

Note that the text titles must remain with their associated picture
and link (I don''t want to scramble all the elements--just rotate the
entire contents of the table cell).

Is there a script that will accomplish this? Thanks.



Perhaps this will give you some ideas.

Test "as is"; watch for word-wrap.

<html>
<head>
<title>rotate26.htm</title>
<script type="text/javascript">
function letters() {
var abc = "abcdefghijklmnopqrstuvwxyz";
var now = new Date();
var pos = now.getSeconds()%26;
var let = abc.substr(pos);
if (pos > 0) let += abc.substring(0,pos);
alert(pos + "\t" + let);
var url = "http://205.200.38.172/aagraphics/letters/letter?.jpg";
var src;
var txt = new Array();
var img = new Array();
for (var i=0; i<let.length; i++) {
src = "<a href=''" + url + "'' target=''_blank''>"
src += "<img src=''" + url + "''";
src += "border=''0'' width=''109'' height=''83'' alt=''?''></a>";
img[i] = src.replace(/\?/g,let.charAt(i));
txt[i] = "<br>The Letter " + let.charAt(i).toUpperCase();
}
var j = 0;
var tab = new Array();
tab[j++] = "<table border=''0'' cellpadding=''0'' cellspacing=''0''
width=''218''>";
var mid = let.length/2;
for (var k=0; k<mid; k++) {
tab[j++] = "<tr height=''100'' valign=''top''>";
tab[j++] = " <th width=''109''>" + img[k] + txt[k] + "</th>";
tab[j++] = " <th width=''109''>" + img[k+mid] + txt[k+mid] +
"</th>";
tab[j++] = "</tr>";
}
tab[j++] = "</table>";
document.write(tab.join(""));
}
letters();
</script>
</head>
<body>
</body>
</html>


Thanks, McKirahan.

I''m still a bit of a newbie at Javascripting, so where do I enter the
values for the cells, images, text and urls?"


"Royal Denning" <ro***********@hotmail.com> wrote in message
news:4e**************************@posting.google.c om...

Thanks, McKirahan.

I''m still a bit of a newbie at Javascripting, so where do I enter the
values for the cells, images, text and urls?"



This should be a little clearer.

<html>
<head>
<title>rotate10.htm</title>
<script type="text/javascript">
function numbers() {
var url = "http://www.scri8e.com/TTF/alphas/redgelharts/";
var gif = new Array();
gif[0] = "0.gif|Zero";
gif[1] = "1.gif|One";
gif[2] = "2.gif|Two";
gif[3] = "3.gif|Three";
gif[4] = "4.gif|Four";
gif[5] = "5.gif|Five";
gif[6] = "6.gif|Six";
gif[7] = "7.gif|Seven";
gif[8] = "8.gif|Eight";
gif[9] = "9.gif|Nine";
for (var i=0; i<gif.length; i++) {
gif[i] = url + gif[i];
}
var hig = 82;
var wid = 46;
var wyd = wid*2;
var ten = "0123456789";
var mod = ten.length;
var now = new Date();
var pos = now.getSeconds()%mod;
var num = ten.substr(pos);
if (pos > 0) num += ten.substring(0,pos);
var col = new Array();
var src;
var sub;
var tmp;
for (var j=0; j<num.length; j++) {
sub = num.charAt(j);
tmp = gif[sub].split("|");
src = "<a href=''" + tmp[0] + "'' target=''_blank''>"
src += "<img src=''" + tmp[0] + "''";
src += "border=''0'' width=''" + wid + "'' height=''" + hig + "''
alt=''''></a>";
src += "<br>" + tmp[1];
col[j] = src;
}
var k = 0;
var tab = new Array();
tab[k++] = "<table border=''0'' cellpadding=''0'' cellspacing=''0''
width=''" + wyd + "''>";
var mid = num.length/2;
for (var l=0; l<mid; l++) {
tab[k++] = "<tr height=''" + hig + "'' valign=''top''>";
tab[k++] = " <th width=''" + wid + "''>" + col[l] + "</th>";
tab[k++] = " <th width=''" + wid + "''>" + col[l+mid] + "</th>";
tab[k++] = "</tr>";
}
tab[k++] = "</table>";
document.write(tab.join(""));
}
numbers();
</script>
</head>
<body>
</body>
</html>

Modify the "gif" array to identify each image followed by a "|" followed by
the text for the image. Change "wid" and "hig" to the "width" and "height"
of the images. This will handle rotating ten images; I''ll leave it toyou to
handle twenty.


这篇关于旋转表格单元格的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆