|
#1
|
|||
|
|||
|
Hi Guys,
Absolute Javascript novice here looking for some guidance with a problem. I am basically trying to change the style of a <span> area when I onclick a radio button. I have achieved this part however when I select another radio button the onlick style remains for the previously selected radipo button. I would like this style to go back to its orginal form once the user has clicked off the radio button. I have uploaded a page for you to see what I mean. All javascript and css is embedde into the page. Any help would be greatly appreciated. http://www.smarthack.com/radiobutton.htm Code:
<html>
<head>
<style type="text/css">
.off{
border-style: solid;
border-collapse: seperate;
border-width: 1;
width: 170px;
border-color : #ffffff #ffffff #ffffff #ffffff;
background: #ffffff;
font-family: verdana;
color: #000000;
}
.on {
border-style: solid;
border-collapse: seperate;
border-width: 1;
width: 170px;
border-color : #4761A1 #000000 #000000 #4761A1;
background: #2C427A;
font-family: verdana;
color: #ffffff;
}
</style>
<script type="text/javascript">
<!--
function toggle(box,theId) {
if(document.getElementById) {
var cell = document.getElementById(theId);
if(box.checked) {
cell.className = "on";
}
else {
cell.className = "off2";
}
}
}
// -->
</script>
</head>
<body>
<span class="off" id="DataCell"> <input type="radio" name="v41" value=" " size="30"
style="font-family: Verdana; font-size: 10pt" onclick="toggle(this,'DataCell')"
checked> Everything</span><br>
<span class="off" id="DataCell1"> <input type="radio" name="v41" value="and
STK_FORM='VI'" size="30" style="font-family: Verdana; font-size: 10pt"
onclick="toggle(this,'DataCell1')"> AV Resources</span><br>
<span class="off" id="DataCell2"> <input type="radio" name="v41" value="and
STK_FORM='BK'" size="30" style="font-family: Verdana; font-size: 10pt"
onclick="toggle(this,'DataCell2')"> Books</span><br>
<span class="off" id="DataCell3"> <input type="radio" name="v41" value="and
STK_FORM='REA'" size="30" style="font-family: Verdana; font-size: 10pt"
onclick="toggle(this,'DataCell3')"> Equipment</span><br>
<span class="off" id="DataCell4"> <input type="radio" name="v41" value="and
STK_STATS_CODE='KIT'" size="30" style="font-family: Verdana; font-size: 10pt"
onclick="toggle(this,'DataCell4')"> Kits<br>
</body>
</html>
Last edited by bigboy99; 04-14-2006 at 02:25 AM. Reason: add code to see |
|
#2
|
||||
|
||||
|
Quote:
Quote:
Quote:
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
|
|