last day (16 days later) » 

5:16 PM
0
A: how to apply different colors for first select and second select checkbox

JayachandranTry this JSFiddle Demo JS: $(function() { $('input[type=checkbox]').each(function() { var span = $('<span class="' + $(this).attr('type') + ' ' + $(this).attr('class') + '"></span>').click(doCheck).mousedown(doDown).mouseup(doUp); if ($(this).is(':checked')) { span.addClass('ch...

 
Thanks buddy, but after uncheck green checkbox the next check should be green but here it see red
 
Try modifying it to fit your specific need. Look in to the else condition inside doCheck().
 
i tried like below but is not working: else if($('#disc').find(":checkbox:checked").length == 1){ $(this).addClass('red'); } else { $(this).addClass('green'); } $(this).children().prop("checked", true); } }
 
Do you want to automatically change red to green when there is only one box checked?
 
no sir, not like that. 1st checkbox should be green and 2nd checkbox should be red. if user unchecked the green and the next selected one should be green color. if user unchecked red means the next check should be red.
 
5:16 PM
Try this please
 
in CSS background we used i48.tinypic.com/raz13m.jpg this image bt i want real check boxes. how can i get?
 
That's a limitation with real checkbox; all options to apply background color depends on custom checkboxes. May be you can create your own sprite with checkboxes which look closer to the real thing.
 
ok sir.. thanq. now i have to know the color of check box and i have to assign value for each color. can you help me?
 
Didn't get you. You want to assign a particular value to the checkbox based on which color background is set?
 
i want to assign green=1 and red=0
i think if($('.green').length > 0) { $(this).addClass('red'); } else { $(this).addClass('green'); } in this block i have to assign but i dnt knw how to assign
 
5:16 PM
This should do for you. Is this some homework assignment? You seem to make me do all your work. Please accept the answer and up-vote it if it helps.
 
it is mini project sir.
if($('.green').length > 0) { $(this).addClass('red'); var y = document.getElementById("myCheck").value; } else { $(this).addClass('green'); var x = document.getElementById("myCheck").value; } $(this).children().prop("checked", true);
i trid above code to store value in varible.. but i want use that variable in php sessions
 
I have provided the fiddle in my last comment. I am leaving this discussion. Forced to comment here because you don't have enough rep to use chat. Anyways, if you found my answer useful, please up vote or accept.
 

  last day (16 days later) »