本人初学php,使用了wamp。被要求做个投票系统,前台的水平却很有限。radio单选框的投票按钮,想做成图片按钮,按照网上的javascript办法http://blog.sina.com.cn/s/blog_5ee2f3730100ec55.html做
点击没有反应,求指正!
<html>
<head>
<meta http-equiv = "content-type" content = "text/html" charset = "gb2312" >
<title>楼盘投票系统_Page1</title>
<style type= "text/css">
.h1{font-family:"微软雅黑";font-size:25px}
</style>
</head>
<body>
<script language = "JavaScript">
function mysid(sid)
{
var omlg = document.getElementsByTagName('img');
for(i = 0;i<omlg.length;i++)
{
if(omlg[i].id==sid)
{
omlg[i].previoussibbling.previoussibbing.checked = true;
omlg[i].style.border= '2px solid #FF6600';
}
else
{
omlg[i].style.border = '2px solid #FFFFFF';
}
}
}
</script>
<div align= "center " valign= "top" margin:-280px style= "display:inline-table;align=center;width=900px;height:110px;padding:20px;background-color:#F6FFD2"><font face = "微软雅黑"size = 7>2011标杆楼盘评选</font>
</div>
<br>
<br>
<div align="left" ><font face = "微软雅黑" size = "6" color = "DA0025" ><b>某某路沿线</b></font></div>
<br>
<br>
<form action = "vote2.php" method = "post" name = "votefm1">
<table align = "left" valign = "top" width = "840" height = "210" cellspace = 0 cellpadding = 2 class="h1" >
<tr>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono1" value = "j1"><b>某某某某城   </b><img id = "jp1"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> <td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono2" value = "j2"><b>某某某某二期  </b><img id = "jp2"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> <td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono3" value = "j3"><b>某某壹号    </b><img id = "jp3"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> </tr>
<tr>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob1" value = "k1"><b>某某城          </b><img id = "kp1"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob2" value = "k2"><b>某某时代         </b><img id = "kp2"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob3" value = "k3"><b>某某某某    </b><img id = "kp3"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
</tr>
</table>
</form> </body>
</html>
点击没有反应,求指正!
<html>
<head>
<meta http-equiv = "content-type" content = "text/html" charset = "gb2312" >
<title>楼盘投票系统_Page1</title>
<style type= "text/css">
.h1{font-family:"微软雅黑";font-size:25px}
</style>
</head>
<body>
<script language = "JavaScript">
function mysid(sid)
{
var omlg = document.getElementsByTagName('img');
for(i = 0;i<omlg.length;i++)
{
if(omlg[i].id==sid)
{
omlg[i].previoussibbling.previoussibbing.checked = true;
omlg[i].style.border= '2px solid #FF6600';
}
else
{
omlg[i].style.border = '2px solid #FFFFFF';
}
}
}
</script>
<div align= "center " valign= "top" margin:-280px style= "display:inline-table;align=center;width=900px;height:110px;padding:20px;background-color:#F6FFD2"><font face = "微软雅黑"size = 7>2011标杆楼盘评选</font>
</div>
<br>
<br>
<div align="left" ><font face = "微软雅黑" size = "6" color = "DA0025" ><b>某某路沿线</b></font></div>
<br>
<br>
<form action = "vote2.php" method = "post" name = "votefm1">
<table align = "left" valign = "top" width = "840" height = "210" cellspace = 0 cellpadding = 2 class="h1" >
<tr>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono1" value = "j1"><b>某某某某城   </b><img id = "jp1"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> <td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono2" value = "j2"><b>某某某某二期  </b><img id = "jp2"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> <td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono3" value = "j3"><b>某某壹号    </b><img id = "jp3"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> </tr>
<tr>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob1" value = "k1"><b>某某城          </b><img id = "kp1"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob2" value = "k2"><b>某某时代         </b><img id = "kp2"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob3" value = "k3"><b>某某某某    </b><img id = "kp3"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
</tr>
</table>
</form> </body>
</html>
解决方案 »
- 如何让并排的div居中
- 哪行代码有阴影效果的啊?郁闷
- 做了一个让用户自动增加文本框的JS
- 关于省市联动的两个问题,困惑,望高手指教!
- web上能实现在线截图,或将剪贴板中的图像粘贴到web上吗?
- "1" == true 为true,"true" == true为false
- 如何写:一个JS的对话框,对话框里面有个文本框,一个确定按键
- 关于eval的问题 请大侠赐教
- 求教asc转换成字符函数
- js判断微信和QQ打开提示在浏览器打开,并识别手机系统给出不同的下载链接
- 大家来研究一下CSDN论坛的筛选得分贴和人的JAVASCRIPT脚本
- js 网页 背景音乐 随机播放 可以点击按钮控制播放与否。怎么实现?
function mysid(sid)
{
alert(sid)
var omlg = document.getElementsByTagName('img');
for(i = 0;i<omlg.length;i++)
{
if(omlg[i].id==sid)
{
omlg[i].previousSibling.previousSibling.checked = true;
omlg[i].style.border= '2px solid #FF6600';
}
else
{
omlg[i].style.border = '2px solid #FFFFFF';
}
}
}
楼主 试试
function myFun(sid)
{
alert(sid);
var omlg = document.getElementsByTagName('img');
for(var i = 0;i<omlg.length;i++)
{
if(omlg[i].id==sid)
{
document.write(omlg[i].id);
omlg[i].previoussibling.previoussibling.checked = true; omlg[i].style.border= '2px solid #FF6600';
}
else
{
omlg[i].style.border = '2px solid #FFFFFF';
}
}
}
</script>加入了document.write(omlg[i].id) 选中的图片的id 值 显示正确,alert(sid) if(omlg[i].id==sid) document.write(omlg[i].id) 和alert(sid) 值相同,证明 onclick 传值 和getElementsByTagName('img')都是没有问题的。似乎问题在对<input type = "raido">的checked 属性的设定上。继续求高手指正啊!
<head>
<meta http-equiv = "content-type" content = "text/html" charset = "gb2312" >
<title>楼盘投票系统_Page1</title>
<style type= "text/css">
.h1{font-family:"微软雅黑";font-size:25px}
</style>
</head>
<body>
<script language = "JavaScript">
function mysid(sid)
{
var omlg = document.getElementsByTagName('img');
for(i = 0;i<omlg.length;i++)
{
if(omlg[i].id==sid)
{
omlg[i].parentNode.getElementsByTagName('input')[0].checked = true;
omlg[i].style.border= '2px solid #FF6600';
}
else
{
omlg[i].style.border = '2px solid #FFFFFF';
}
}
}
</script>
<div align= "center " valign= "top" margin:-280px style= "display:inline-table;align=center;width=900px;height:110px;padding:20px;background-color:#F6FFD2"><font face = "微软雅黑"size = 7>2011标杆楼盘评选</font>
</div>
<br>
<br>
<div align="left" ><font face = "微软雅黑" size = "6" color = "DA0025" ><b>某某路沿线</b></font></div>
<br>
<br>
<form action = "vote2.php" method = "post" name = "votefm1">
<table align = "left" valign = "top" width = "840" height = "210" cellspace = 0 cellpadding = 2 class="h1" >
<tr>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono1" value = "j1"><b>某某某某城 </b><img id = "jp1"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> <td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono2" value = "j2"><b>某某某某二期 </b><img id = "jp2"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> <td width = "280" valign = "top" height = "35"><input type = "radio" name = "radiono3" value = "j3"><b>某某壹号 </b><img id = "jp3"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td> </tr>
<tr>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob1" value = "k1"><b>某某城 </b><img id = "kp1"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob2" value = "k2"><b>某某时代 </b><img id = "kp2"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
<td width = "280" valign = "top" height = "35"><input type = "radio" name = "radionob3" value = "k3"><b>某某某某    </b><img id = "kp3"src="http://img2081.poco.cn/mypoco/myphoto/20110906/16/5636976620110906164630040.png" width="80" height="30" border="0" onclick = "mysid(this.id)" /></td>
</tr>
</table>
</form> </body>
</html>