Javascript to change check box background color on clickVVivekh15yAsked Jun 29, 2011, 3:16 AM EDT6 answersShareLinkedInXCopy linkSaveI have a fiddle for this which is working for Input check boxes the same i would like to have for asp check boxes how can ihttp://jsfiddle.net/Town/B2n2J/
Javascript to change check box background color on clickVVivekh15yAsked Jun 29, 2011, 3:16 AM EDT6 answersShareLinkedInXCopy linkSaveI have a fiddle for this which is working for Input check boxes the same i would like to have for asp check boxes how can ihttp://jsfiddle.net/Town/B2n2J/
Mahak GuptaRank #138 · 16.2K reputation15y agoPosted Jun 29, 2011, 5:01 AM EDT0First we take a CheckBox( chk1)On the onclick event of the chk1 we write the following javascript function (Show()), to change the color of the chk1 backgroundJavascript function:0
VVivekh10 reputation15y agoPosted Jun 29, 2011, 5:06 AM EDT0Hi but if i use asp control this doesn't work for me this is what i have written function Show() { document.getElementById('chkExit').style.backgroundColor = 'Blue'; } onclick="Show();" AutoPostBack="True" OnCheckedChanged="chkExit_CheckedChanged" />0Suthish NairRank #92 · 22.8K reputation15y agoPosted Jun 29, 2011, 7:10 AM EDT0 Instead of using onclick use onchange and try.. Or on Page Load chkExit.Attributes.Add("onchange", "Show()");0GVGagan Verma2 reputation11y agoPosted Oct 24, 2015, 1:37 AM EDT0hello mahak,,it is giving me 404 not fount error when i try to download checkbox.rar file.0Munesh SharmaRank #174 · 13.9K reputation11y agoPosted Oct 24, 2015, 3:07 AM EDT0Add 'this' to the calling function: name="checkbox_{{ word.id }}" onclick="highlight_row('row_{{ forloop.counter }}',this)" /> Now you can use the checked state of the chechbox to determine what to do: function highlight_row(row_id,checkbox) { var row = document.getElementById(row_id); row.style.background = checkbox.checked ? "yellow" : ""; }0Munesh SharmaRank #174 · 13.9K reputation11y agoPosted Oct 24, 2015, 3:07 AM EDT0http://jsfiddle.net/7wnCL/20/0Join to answer this questionEvery answer you publish earns 20 SHARP.Create free accountSign inKnow the answer?Answer a question in the forums and earn +20 SHARP for every answer.See unanswered questionsForumsTop experts01Arun PottiAnswers in the forums20answers02Tahir AnsariAnswers in the forums5answers03Kamlesh KumarAnswers in the forums5answers04Sam HobbsAnswers in the forums4answers05Željko PerićAnswers in the forums3answers?YouYour name goes here.Every answer: 20 SHARP.JoinFull leaderboard →2026DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Suthish NairRank #92 · 22.8K reputation15y agoPosted Jun 29, 2011, 7:10 AM EDT0 Instead of using onclick use onchange and try.. Or on Page Load chkExit.Attributes.Add("onchange", "Show()");0
GVGagan Verma2 reputation11y agoPosted Oct 24, 2015, 1:37 AM EDT0hello mahak,,it is giving me 404 not fount error when i try to download checkbox.rar file.0
Munesh SharmaRank #174 · 13.9K reputation11y agoPosted Oct 24, 2015, 3:07 AM EDT0Add 'this' to the calling function: name="checkbox_{{ word.id }}" onclick="highlight_row('row_{{ forloop.counter }}',this)" /> Now you can use the checked state of the chechbox to determine what to do: function highlight_row(row_id,checkbox) { var row = document.getElementById(row_id); row.style.background = checkbox.checked ? "yellow" : ""; }0
Munesh SharmaRank #174 · 13.9K reputation11y agoPosted Oct 24, 2015, 3:07 AM EDT0http://jsfiddle.net/7wnCL/20/0
Mahak GuptaRank #138 · 16.2K reputationPosted Jun 29, 2011, 5:01 AM EDT
On the onclick event of the chk1 we write the following javascript function (Show()), to change the color of the chk1 background
Javascript function:
Vivekh10 reputationPosted Jun 29, 2011, 5:06 AM EDT
Suthish NairRank #92 · 22.8K reputationPosted Jun 29, 2011, 7:10 AM EDT
Instead of using onclick use onchange and try..
Or on Page Load
chkExit.Attributes.Add("onchange", "Show()");
Gagan Verma2 reputationPosted Oct 24, 2015, 1:37 AM EDT
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 24, 2015, 3:07 AM EDT
Add 'this' to the calling function:
name="checkbox_{{ word.id }}"
onclick="highlight_row('row_{{ forloop.counter }}',this)" />
Now you can use the checked state of the chechbox to determine what to do:
function highlight_row(row_id,checkbox)
{
var row = document.getElementById(row_id);
row.style.background = checkbox.checked ? "yellow" : "";
}
Munesh SharmaRank #174 · 13.9K reputationPosted Oct 24, 2015, 3:07 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts