LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-29-2004, 01:08 AM   #1
akaash
LQ Newbie
 
Registered: Mar 2004
Location: Gujarat, India
Posts: 22

Rep: Reputation: 15
color change on checkbox click


how can i change the backgroud color of tag whenever i click on the checkbox in it.

I mean as soon as the user checks or unchecks the checkbox then the bgcolor of the corresponding
tag should change.

...just as it is done in yahoo mail,
 
Old 03-29-2004, 12:36 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
I don't use yahoo but why not just look at the source for their page?

You could try something like:
Code:
<HTML>
<HEAD>
<TITLE>Checkbox Example</TITLE>
</HEAD>
<BODY>
<SCRIPT language="javascript" type="text/javascript">
function swapcol(item){
 if(document.getElementById(item).checked){
  document.getElementById(item+'bg').style.background='#00FFFF'
 }
 else{
  document.getElementById(item+'bg').style.background='#FFFFFF'
 }
}
</SCRIPT>
<FORM action="#" name="form">
<DIV id="item1bg">Checkbox 1: <INPUT type="checkbox" id="item1" name="checkbox" onclick="swapcol('item1')"></DIV>
<DIV id="item2bg">Checkbox 2: <INPUT type="checkbox" id="item2" name="checkbox" onclick="swapcol('item2')"></DIV>
<DIV id="item3bg">Checkbox 3: <INPUT type="checkbox" id="item3" name="checkbox" onclick="swapcol('item3')"></DIV>
<DIV id="item4bg">Checkbox 4: <INPUT type="checkbox" id="item4" name="checkbox" onclick="swapcol('item4')"></DIV>
<DIV id="item5bg">Checkbox 5: <INPUT type="checkbox" id="item5" name="checkbox" onclick="swapcol('item5')"></DIV>
</FORM>
</BODY>
</HTML>

Last edited by david_ross; 03-29-2004 at 12:38 PM.
 
Old 03-29-2004, 11:00 PM   #3
akaash
LQ Newbie
 
Registered: Mar 2004
Location: Gujarat, India
Posts: 22

Original Poster
Rep: Reputation: 15
Thank u very much it worked..
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
change mouse click behaviour nadroj Linux - Newbie 10 01-23-2005 09:25 PM
change color vito_huang Linux - General 1 11-13-2004 01:21 PM
Change Konqueror/Desktop single-click behaviour robertmarkbram Linux - Software 2 10-08-2003 10:58 PM
ls --color 'color change' ekdya Linux - General 1 10-06-2003 03:47 PM
counsol color change crealkillerI75 Slackware 8 07-27-2002 06:36 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration