Highlighting between two data points on a scale
I have a php generated scale table from 1 to 14. I highlight the min and max values given by the checkbox form on the table with the following jquery code.
This is the jquery code I'm using to highlight two points on the scale table.
- $("#checkAll").click(function() {
- $('input:checkbox').not(this).prop('checked', this.checked)
- .trigger("change");
- });
- $(".selector").on("change", function() {
- var parent = $(this).closest("form");
- $("#" + parent.data("checktable"))
- .find('[dbval="' + this.name + '"]')
- .toggleClass("highlight", $(this).is(":checked"));
- parent
- .find(".all")
- .prop(
- "checked",
- parent.find(".selector:checked").length === parent.find(".selector").length
- );
- });
- $(".all").on("change", function() {
- $(this).closest("form").find(".selector")
- .prop("checked", $(this).is(":checked"))
- .trigger("change");
- });
- $(".all:checked").each(function() {
- $(this).closest("form").find(".selector").prop("checked", true).trigger("change");
- });
- $(".selector").trigger("change");
Normally I mostly have two values (min and max), but sometimes there happens to be a single value (either min or max) to be highlighted, or no values at all (no highlight). I need to highlight not only the min and max values but all the values between the minimum and maximum values.
For example if (min,max) is (2,8), then 2,3,4,5,6,7, and 8 should be highlighted. How can I get this result? Thanks.