How to Highlight Selected Items inside Checkbox List K2 Smartform.

Hello There, let’s see a simple CSS & JavaScript technique to highlight the selected items of a checkbox list inside a K2 smart form.

As you know K2 choice control as a checkbox list doesn’t have much options to highlight the selected items, we can use this simple JavaScript code to highlight the background of selected items which will update automatically on change of selection. Please find the script below.

<script>

$(“.checked”).css(“background-color”, “#d4ffaa”);

$(‘[name=”ChoiceData”]:checkbox’).on(‘change’, function(){

   if(this.checked)

    {

        this.parentElement.setAttribute(‘style’, ‘background-color: #d4ffaa;’);

    }

    else{

      this.parentElement.setAttribute(‘style’, ‘background-color: white;’);

   }

});

</script>

Change the name inside the script as per your Choice control’s name, in my case choice control’s name is “ChoiceData

Inject this script into smartform using a datalabel and expression and that’s it. Check the magic as shown in demo below.

Note: Here I have used Choice Control as Checkbox List. I haven’t tested this with actual CheckBox List Control.

Bagi2info.com

Tips dan Trik Komputer, Tutorial Pemrograman, SQL, PHP, React Native - Expo

Mohamed Ashiq Faleel

Its time to think about Microsoft 365

Common Man Tips for Power Platform, Dynamics CRM,Azure

Venkata Subbarao Polisetty - Microsoft MVP,C# Corner MVP

James K2 Blog

Tips and Tricks about K2 workflow software

the BPM freak !!

"The illiterate of the 21st century will not be those who cannot read and write, but those who cannot learn, unlearn, and relearn" – Alvin Toffle

Start Rule

Learning K2 blackpearl and K2 Five

K2Ranger

Do K2 like a BOSS!!

Maverick

discover your own way and lead the world... with Divya Raj

jeylabs

Work Intelligently

Chasing Time - Mobile Gaming Photography Tips Tricks

#iamtheiosphotographer Pro Mobile Game Reviews, Tips, Tri

Jozsef Torsan

Founder & Software Engineer - Creator of the Bookmark Ninja Online Bookmark Manager

GreenEggs on K2

Saving the world with K2