作者earth999 (道格拉屎)
看板PHP
标题[请益] 关於图片赋予数值并传出的问题
时间Mon Aug 20 19:41:38 2012
<body>
<tr>
<?php
for ($i = 1; $i <= 26; $i ++) {
echo '<td>'. $i .'</td>';
}
?>
</tr>
<tr>
<?php
for ($j = 1; $j <= 26; $j ++) {
echo '<td><img src="01.gif" rel="01.gif,02.gif,03.gif" name="vid_chk"
id="vid_chk'. $j .'" value="1" /></td>';
}
?>
<script type="text/javascript">
//切换图片
(function () {
var imgs = document.getElementsByTagName('img');
for (var i=0,L=imgs.length; i<L; i++)
{
var img = imgs[i], rel = img.getAttribute('rel');
img.pic = rel && rel.split(/\s*,\s*/) || [];
img.current = 0;
img.onclick = function(){
this.current++;
if (this.current >= this.pic.length) {this.current = 0;}
this.src = this.pic[this.current];
}
}
})();
</script>
</tr>
<body>
我要做一行26格的图片切换选项
现在图片是可以切换了,但是我现在需要把图片变成一个值然後传出去
就好比我在第一格我图片切换到02.gif,图片会送出值value=1
当按下送出按钮,如果第一格图片是02.gif值是1,最後按下送出是一长串26个数字
好比10000000000000000000000000(0就当作是01.gif的值为预设值)
真不知道图片要怎传值出去,麻烦解惑
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.27.75.206
1F:→ iceblue7x:img没有value属性 你可以每张图配1个 hidden input 08/20 22:40
2F:→ earth999:type=hidden id="" value=../01.gif ? 08/21 11:23
3F:→ earth999:$gif_1=$_POST['gif_1']; $gif_1=1; 这样? 08/21 11:24
4F:→ Bambe:楼上,name不见了 Orz 08/21 12:48
5F:→ earth999:我回文没打上 但实际程式码上有 08/21 13:02