日期:2014-05-16  浏览次数:20353 次

单选框图片显示
有三个单选框~~每个对应一张图片~~~
选中一个单选框后~~~会把对应的图片显示在上面的 <div> 层中
的js怎么写
<div>
</div>
<hr>
<form   name=f1   id=f1>
<table   border= "1 "   cellpadding= "0 "   cellspacing= "1 "   bordercolor= "#CCCCCC ">
<tbody>
<tr>
<td> <input   type= "radio "   value= "07 "   name= "webmodel "   /> NO.01 </td>
</tr>
<tr>
<td   bgcolor= "#ffffff "> <a   href= "# "> <img   src= "1.jpg "   width= "140 "   height= "200 "   border= "0 "   /> </a> </td>
</tr>
</tbody>
</table> </td>
<td> <table   border= "1 "   cellpadding= "0 "   cellspacing= "1 "   bordercolor= "#CCCCCC ">
<tbody>
<tr>
<td> <input   type= "radio "   value= "07 "   name= "webmodel "   /> NO.02 </td>
</tr>
<tr>
<td   bgcolor= "#ffffff "> <a   href= "# "> <img   src= "2.jpg "   width= "140 "   height= "200 "   border= "0 "   /> </a> </td>
</tr>
</tbody>
</table> </td>
<td> <table   border= "1 "   cellpadding= "0 "   cellspacing= "1 "   bordercolor= "#CCCCCC ">
<tbody>
<tr>
<td> <input   type= "radio "   value= "07 "   name= "webmodel "   /> NO.03 </td>
</tr>
<tr>
<td   bgcolor= "#ffffff "> <a   href= "# "> <img   src= "3.jpg "   width= "140 "   height= "200 "   border= "0 "   /> </a> </td>
</tr>
</tbody>
</table>
</form>

------解决方案--------------------
<html>
<style>
</style>
<script>
function showPic(picUrl)
{
document.getElementById( "dv ").style.backgroundImage = "url( "+picUrl+ ") ";
document.getElementById( "dv ").style.width=140;
document.getElementById( "dv ").style.height=200;
}
</script>
<body>
<div id=dv>
</div>
<hr>
<form name=f1 id=f1>
<table border= "1 " cellpadding= "0 " cellspacing= "1 " bordercolor= "#CCCCCC ">
<tbody>
<tr>
<td> <input type= "radio " value= "07 " name= "webmodel " onclick= "showPic( '1.jpg ') "/> NO.01 </td>
</tr>
<tr>
<td bgcolor= "#ffffff "> <a href= "# "> <img src= "1.jpg " width= "140 " height= "200 " border= "0 " /> </a> </td>
</tr>
</tbody>
</table> </td>
<td> <table border= "1 " cellpadding= "0 " cellspacing= "1 " bordercolor= "#CCCCCC ">
<tbody>