samedi 20 février 2021

How to clear checkbox and alert if I select YES or NO?

I have a set of list selection field above as YES and NO within a fieldset. And a set of checkboxes in another fieldset below.

What I expect to happen via a jquery is

  • If I select NO in the list above, an alert should appear and checkboxes below will clear out. I have tried the following but not able to get it work. Can anyone help please? Thanks
     $('#enable_email').change(function() {
     if ($('#enable_email').attr("value")=="NO"))) {
          Swal.fire({
              title: 'Alert'
            });
    $("input[name=group_101]").removeAttr('checked');
          }
<div class="crm-communications-preferences-form-block crm-public">
    
        <div class="comm-pref-block groups-block">
    
        <fieldset id="crm-communications-preferences-channels">
            <div class="crm-section">
            <div class="label"><label for="enable_email">  Email Newsletter
         <span class="crm-marker" title="This field is required.">*</span>
    </label></div>
            <div class="content"><select name="enable_email" id="enable_email" class="crm-form-select required">
        <option value="">--Select--</option>
        <option value="YES" selected="selected">Yes</option>
        <option value="NO">No</option>
    </select></div>
          </div>
                        </fieldset>
                </div>
    </div>

        <!-- Groups from settings -->
        <div class="comm-pref-block groups-block">
    
            <!-- Groups Fieldset -->
    <fieldset id="crm-communications-preferences-groups" class="groups-fieldset">
    <div class="crm-section">
    <div class="content group-channel-div">
    <input id="group_101" name="group_101" type="checkbox" value="1" checked="checked" class="crm-form-checkbox">
<label for="group_101">Newsletter</label>
        <span class="group-description">Monthly Newsletter</span>
                 </div>
                  </div>
    <div class="crm-section">
    <div class="content group-channel-div">
    <input id="group_102" name="group_102" type="checkbox" value="1" checked="checked" class="crm-form-checkbox">
                        <label for="group_102">Communications</label>
        <span class="group-description">Relating Activities</span>
                 </div>
                  </div>
                </fieldset>
                </div>
    </div>




WordPress: Why doesn't custom field checkbox appear in the template, but only its label and instruction

I created a custom field group with two fields one of which is a checkbox. The checkbox doesn't appear, but its label and the instruction for the checkbox, so I cannot click the actual checkbox. I don't seem to have missed any setting for the checkbox while creating it.

enter image description here




How to assign a List of Booleans to a generated Checkbox IsChecked property in WPF?

I've recently started learning C# and I've encountered a problem. I display a set of keywords in a generated checkbox in my WPF and I want to check the element (IsChecked) based on an input check from a TXT file. If the currently selected element from a different listbox matches the read modelclass(from a txt file) then set the checked key true.

I'm generating a Checkbox in my WPF to list a set of keywords that my app reads from a txt file. The txt file contains the following items per line: -id -key -pair -description

WPF code:


 <ListView ItemsSource="{Binding XAMLModelKeywords}" SelectedItem="{Binding XAMLModelKeyword}" Margin="5" x:Name="listofallkeys" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" >
        <ListView.ItemTemplate>
            <DataTemplate>
                <CheckBox IsChecked="{Binding XAMLAssignedKeys}" Content="{Binding Key}"/>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

C#:

        public ModelTemplates XAMLModelTemplate { get; set; }

        public ModelKeywords XAMLModelKeyword { get; set; }
        public List<bool> XAMLAssignedKeys { get; set; }


        public string XAMLKeyword { get; set; }

        public ViewModelMain()
        {
            //This creates a new instance of ObservableCollection above
            XAMLModelTemplates = new ObservableCollection<ModelTemplates>();
            XAMLModelKeywords = new ObservableCollection<ModelKeywords>();
            XAMLAssignedKeys = new List<bool>();
            Refresh();
        }

     public void Refresh()
        {
            XAMLModelTemplates.Clear();
            foreach (ModelTemplates tpl in ReadInput.ReadTemplateDirectory(Path))
            {
                XAMLModelTemplates.Add(tpl);
            }
            //Selecting the first item from the returned list
            XAMLModelTemplate = XAMLModelTemplates.FirstOrDefault();
    
            XAMLModelKeywords.Clear();
            foreach (ModelKeywords tpl in ReadInput.ReadKeywordsFile(KeyWordsPath))
            {
                XAMLModelKeywords.Add(tpl);
            }
            XAMLModelKeyword = XAMLModelKeywords.FirstOrDefault();
    
            XAMLAssignedKeys.Clear();
            foreach (ModelKeywords tpl in XAMLModelKeywords)
            {
    
                XAMLAssignedKeys.Add(ReadInput.CheckPairedtemplates(tpl, XAMLModelTemplate));
            }

ReadKeywordsFile: Returns a list of Template Models (name of template file, path) and the displays it in a listbox.

ReadKeywordsFile: Returns a list of Keywords Model (id, key, pair, desc) and then displays it in a generated listbox.

CheckPairedtemplates: Returns a list of booleans based on the currently selected Template Model matches the Keywords Model pair (list of string).

TLDR: I have a list of booleans ( XAMLAssignedKeys) and I want to match it to my generated checkbox in WPF, however the generation happens based on an item template and I'm not sure how to link one element from my list of booleans to the checkbox "IsChecked" property.

ScreenshotofApp

Thank you much in advance for the advices.




Customization of checkboxes and radio buttons without hiding default ones

Is there any way of changing default color of checkboxes and radio buttons before and after click without hiding and replacing default ones?




change html label background if checkbox is checked with plain css [duplicate]

How should the label's background for a checked checkbox be set in plain CSS? I got something that changes the background of the Ballet Box span, but I need the complete label to have this color without javascript.

I tried several combinations of label, input-box-selectors and styling the checkbox in another way.

See https://jsfiddle.net/7haorjcs/ for running CSSE.

Thanks for all suggestions. :-)

<html>
<head>
  <meta charset="UTF-8">
  <title>CheckboxTest</title>
  <style type="text/css">
body {
  margin: 20px;
  background: #FFFFFF;
  font-family: 'Trebuchet MS', 'Open Sans', sans-serif;
  color: #000000;
}
.cbx {
  text-decoration: none;
  color: #FFFFFF;
  background-color: #ff6633;
  cursor: pointer;
  border: 2px solid;
  border-color: #002080;
  border-radius: 4px;
  padding: 2px 5px;
  display: inline-block;
  font-weight: bold;
  font-size: x-large;
}
.cbx:hover {
  color: #000000;
  background-color: #ffe066;
}
.cbxcm:checked + span { /* the span changes color, but not the complete label */
  background-color: #336600;
}
.cbxcm:checked:hover + span { /* the span changes color, but not the complete label */
  background-color: #ffe066;
}
.cbxcm {
  display: none;
}
.cbxcm + span {
  color: #ffd633;
}
.cbxcm + span:after {
  content: "\2610";
  font-style: bold;
  font-size: x-large;
  margin-left: 10px;
}
.cbxcm:hover + span {
  color: #005500;
}
.cbxcm:checked + span {
  color: #66ff33;
}
.cbxcm:checked + span:after {
  content: "\2612";
}
.cbxcm:checked:hover + span:after {
  color: #555555;
}
  </style>
</head>
<body>
<div class="outer">
  <div class="content" id="content">
  <label class="cbx">Text
    <input class="cbxcm" type="checkbox"><span></span></label>
  <br><br>
  <label class="cbx">Some more Text
    <input class="cbxcm" type="checkbox"><span></span></label>
  <br><br>
  <label class="cbx">Different
    <input class="cbxcm" type="checkbox" checked="checked"><span></span></label>
  </div><br>
  <div class="footer">
    <div id="console"></div>
  </div>
</div>
</body>
</html>



How can I get the values of checked checkbox inside the jTable and calculate they average in Java

I am trying to create a rating prototype in java, were a use can rate the aspect by clicking the checkbox. I am trying to capture the values for selected checkbox inside the table and calculate they average. And I want the user to be able to select only one checkbox in each row.

See the image to get a clear idea of what I mean

enter code here

    int rating;
    int checkBox;
    int average = 0;
    
    for(int a=0; a<jTable1.getRowCount(); a++){
        
        Boolean isChecked = Boolean.valueOf(jTable1.getValueAt(a, +1).toString());
            if (isChecked) {
                rating =+1;
            //get the values of the columns you need.
            } else {
            System.out.printf("Row %s is not checked \n", a);
            
            
}
        for(int c=1; c<jTable1.getColumnCount(); c++){
            
            
        
            //if( jTable1.getValueAt(c, 1).isSelected()==true){
               //rating = 1;
            //}
        }  
    }

See the image here to have a clear idea of what i am saying




vendredi 19 février 2021

Not able to remove check from select all checkbox Ng2 smart table

As you see from the image, when I deselect any row individually, the select all checkbox in the header remains checked.

enter image description here

Is there any solution?