
05.05.2008, 17:47
|
|
Постоянный
Регистрация: 30.08.2007
Сообщений: 773
Провел на форуме: 3069349
Репутация:
808
|
|
а как сделать тоже самое с radio?
Код:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
#container { margin: 10px 0; }
#container div
{
background: #EEE;
width: 100px;
height: 75px;
border: #AAA solid 1px;
padding: 0 3px;
font-size: small;
}
div.show { display: block; }
div.hide { display: none; }
</style>
<script type="text/javascript">
function toggle(id, a)
{
var node = document.getElementById(id),
i = a.length;
while(i--)
{
if(a[i].checked)
{
var blocks = node.getElementsByTagName('div'),
l = blocks.length;
while(l--)
{
blocks[l].className = 'hide';
}
blocks[i].className = 'show';
break;
}
}
};
</script>
</head>
<body>
<div id="container">
<div class="show">1</div>
<div class="hide">2</div>
<div class="hide">3</div>
<div class="hide">4</div>
<div class="hide">5</div>
<div class="hide">6</div>
<div class="hide">7</div>
<div class="hide">8</div>
<div class="hide">9</div>
<div class="hide">10</div>
</div>
<form onclick="toggle('container', this.filetype)" action="javascript:alert('submitted')">
<input name="filetype" type="radio"> 1<br>
<input name="filetype" type="radio"> 2<br>
<input name="filetype" type="radio"> 3<br>
<input name="filetype" type="radio"> 4<br>
<input name="filetype" type="radio"> 5<br>
<input name="filetype" type="radio"> 6<br>
<input name="filetype" type="radio"> 7<br>
<input name="filetype" type="radio"> 8<br>
<input name="filetype" type="radio"> 9<br>
<input name="filetype" type="radio"> 10<br>
</form>
</body>
</html>
|
|
|