1

I am having checkboxes in a table of 23 columns and 7 rows. I want to style checkboxs in such a way that , hide the check mark when selected. To identify the checked items , I need to change the background image of the checkbox like fill it with a color. Can someone tell me how can this be done in Jquery/Javascript and CSS? I tried using Javascript plugin from http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/custom-form-elements.js Included this Js in my php page added class= styled. It dosen't seem to be working.

Here is the code of my checkbox:

 <div id="checkboxes">
          <table id="custom-interval-tbl" class="form-layout" cellpadding="0" cellspacing="0">
              <?php foreach($days_of_week as $short => $long): ?>
                <tr>
                      <th scope="row"><?echo"<b>".$short."</b>"?></b></th>
                      <?php for($hour = 0; $hour <= 23; ++$hour): ?>
                        <td><input type="checkbox" class="styled" name="custom_interval[<?=$short?>][<?=$hour?>]" value="<?=$hour?>" <?=isset($custom_intervals[$short][$hour]) ? 'checked="checked"' : ''?> /></td>
                      <?php endfor; ?>
                </tr>
                 <?php endforeach; ?>
          </table>
          </div>
        </div>

Do I need to change anything in the script? Thanks for our suggestions.

user1028428
  • 81
  • 1
  • 5
  • 13
  • Imagine us reading your question... how could you help by just having the info provided in the question? – Roko C. Buljan Aug 09 '12 at 17:55
  • 1
    Sounds like you're stomping on default functionality of the checkbox. Don't do that. Create your own custom element. – Gabe Aug 09 '12 at 17:55
  • Possible duplicate: http://stackoverflow.com/questions/4148499/how-to-style-checkbox-using-css – Alexander Aug 09 '12 at 17:56
  • Helpful hint here. If you're trying to solve a Javascript/jQuery/HTML/CSS problem then please don't clutter up the code sample with PHP script that isn't really part of the problem, we don't need to see that. Just give us a straight js/jq/HTML/CSS snippet instead (and optionally an example on jsFiddle). Trying to read the code above is hard and many users will just walk on by. Thanks. – Kev Aug 11 '12 at 01:22
  • http://stackoverflow.com/a/12193350/89509 – Blake Pettersson Aug 31 '12 at 10:02

4 Answers4

0
$(document).ready(function() {
  $('input:checkbox').on('change', function(){
    $(this).hide();
 }
});
Mark
  • 6,762
  • 1
  • 33
  • 50
0

You can use this form element styling jquery plugin.

http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/

Just you need to use a background image without checked icons.

Attached a sample background image to use withoud checked icons. you can simply replace it with original one. enter image description here

Abhishek
  • 838
  • 1
  • 6
  • 9
-1

Put this code in your css file:

 input[type="checkbox"]:focus{
 outline:none !important; }

Here :focus indicates the state when you select a checkbox. And outline attribute points the outline (but on focus as in code). It will affect all the checkboxes in your table, and won't show any checkmark after selecting.

4b0
  • 21,981
  • 30
  • 95
  • 142
Aksh1693
  • 59
  • 7
-1
document.getElementById("input_checkbox_id").checked = false;
Samuel Liew
  • 76,741
  • 107
  • 159
  • 260