in Education by
There is no way to have a tri-state check button (yes, no, null) in HTML, right? Are there any simple tricks or work-arounds without having to render the whole thing by oneself? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Edit — Thanks to Janus Troelsen's comment, I found a better solution: HTML5 defines a property for checkboxes called indeterminate See w3c reference guide. To make checkbox appear visually indeterminate set it to true: element.indeterminate = true; Here is Janus Troelsen's fiddle. Note, however, that: The indeterminate state cannot be set in the HTML markup, it can only be done via Javascript (see this JSfiddle test and this detailed article in CSS tricks) This state doesn't change the value of the checkbox, it is only a visual cue that masks the input's real state. Browser test: Worked for me in Chrome 22, Firefox 15, Opera 12 and back to IE7. Regarding mobile browsers, Android 2.0 browser and Safari mobile on iOS 3.1 don't have support for it. Previous answer Another alternative would be to play with the checkbox transparency for the "some selected" state (as Gmail does used to do in previous versions). It will require some javascript and a CSS class. Here I put a particular example that handles a list with checkable items and a checkbox that allows to select all/none of them. This checkbox shows a "some selected" state when some of the list items are selected. Given a checkbox with an ID #select_all and several checkboxes with a class .select_one, The CSS class that fades the "select all" checkbox would be the following: .some_selected { opacity: 0.5; filter: alpha(opacity=50); } And the JS code that handles the tri-state of the select all checkbox is the following: $('#select_all').change (function () { //Check/uncheck all the list's checkboxes $('.select_one').attr('checked', $(this).is(':checked')); //Remove the faded state $(this).removeClass('some_selected'); }); $('.select_one').change (function () { if ($('.select_one:checked').length == 0) $('#select_all').removeClass('some_selected').attr('checked', false); else if ($('.select_one:not(:checked)').length == 0) $('#select_all').removeClass('some_selected').attr('checked', true); else $('#select_all').addClass('some_selected').attr('checked', true); }); You can try it here: http://jsfiddle.net/98BMK/ Hope that helps!

Related questions

0 votes
    I've successfully floated labels above form input fields when focused, but I'm stumped on how to keep ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    Consider the following code. What is a good hashing function for the array in Key to be used in ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I am new to VBA and I'm trying to create a form in Access where a text box is enabled or ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 5, 2022 in Education by JackTerrance
0 votes
    To lower the file size, while uploading, in Scratch, check the _________ box in the left corner of the upload screen Select the correct answer from above options...
asked Dec 14, 2021 in Education by JackTerrance
0 votes
    I'm currently developing my first python program, a booking system using tkinter. I have a customer account ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    state true false the name box shows the controls of the active cell Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    Write short note on : Journey from Ballot box to EVM machine : Please answer the above question....
asked Aug 14, 2022 in Education by JackTerrance
0 votes
    This script extracts data from check boxes in order to determine the information a form sends to PayPal. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I'm trying to unload data from a Redshift cluster in one box to an S3 bucket in another box. I ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I'm trying to unload data from a Redshift cluster in one box to an S3 bucket in another box. I ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I need to build a pop up dialog box in my app. I am using Dialog class and wrapped it with ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 3, 2022 in Education by JackTerrance
0 votes
    I am trying to do some validation on the file name before it's saved. Here are my three file- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I wrote the following code to quickly grab and display information from Wikipedia. It works great unless the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    When assigning a background color of a table cell on hover, the box shadow is covered. I have found ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    The Cookies Preferences box that always appears in the bottom right hand corner of the dataplatform.ibm.com ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
...