Go Back   Dynamic Drive Forums > General Coding > JavaScript
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-14-2006, 02:14 AM
bigboy99 bigboy99 is offline
New Comer (less than 5 posts)
 
Join Date: Apr 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default onclick radio button style

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">&nbsp;<input type="radio" name="v41" value=" " size="30" 

style="font-family: Verdana; font-size: 10pt" onclick="toggle(this,'DataCell')" 

checked>&nbsp;&nbsp;Everything</span><br>
<span class="off" id="DataCell1">&nbsp;<input type="radio" name="v41" value="and 

STK_FORM='VI'" size="30" style="font-family: Verdana; font-size: 10pt" 

onclick="toggle(this,'DataCell1')">&nbsp;&nbsp;AV Resources</span><br>
<span class="off" id="DataCell2">&nbsp;<input type="radio" name="v41" value="and 

STK_FORM='BK'" size="30" style="font-family: Verdana; font-size: 10pt" 

onclick="toggle(this,'DataCell2')">&nbsp;&nbsp;Books</span><br>
<span class="off" id="DataCell3">&nbsp;<input type="radio" name="v41" value="and 

STK_FORM='REA'" size="30" style="font-family: Verdana; font-size: 10pt" 

onclick="toggle(this,'DataCell3')">&nbsp;&nbsp;Equipment</span><br>
<span class="off" id="DataCell4">&nbsp;<input type="radio" name="v41" value="and 

STK_STATS_CODE='KIT'" size="30" style="font-family: Verdana; font-size: 10pt" 

onclick="toggle(this,'DataCell4')">&nbsp;&nbsp;Kits<br>



</body>
</html>

Last edited by bigboy99; 04-14-2006 at 02:25 AM. Reason: add code to see
Reply With Quote
  #2  
Old 04-14-2006, 02:34 PM
Twey's Avatar
Twey Twey is offline
Modtoreador
 
Join Date: Jun 2005
Location: 英国
Posts: 11,933
Thanks: 1
Thanked 180 Times in 172 Posts
Blog Entries: 2
Default

Quote:
Code:
cell.className = "off2";
Is this defined?
Quote:
Code:
font-size: 10pt
pts are designed for use on printable media, and can be highly variable onscreen.
Quote:
Code:
value="and STK_FORM='VI'"
Nothing to do with your question, but this looks as if you're going to put that straight into an SQL query later. Don't. This is very open to SQL injection.
__________________
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!
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:21 AM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.