mardi 31 août 2021

passing multiple values from input checkbox in codeigniter not working

i have a codeignter form, from where i try to pass values of multiple checkboxes and display it in another view page, the view is like:

<tbody>
  <?php
     $i=1;
    foreach($selectexcel as $val){?>
    <tr>
      <th scope="col"><input type="checkbox" id="checkItem" name="printtype[]" value="<?=$val->id?>" /></th>
      <th scope="row">
        <?= $i?>
      </th>
      <th scope="row"><?= $i?></th>
      <td><?= $val->batchnumber?></td>
    
      <td>
        <button type="submit" name="savemeda" style="margin-left:5px; font-size: 0.6em;" class="btn btn-warning">PRINT</button></td>
    </tr>
    <?php $i++; } ?>
</tbody>

below is my controller:

  public function printconsignment() {
    $data = array();
    if($this->isUserLoggedIn){
        $con = array(
            'id' => $this->session->userdata('userId')
        );

            if(isset($_POST['savemeda']))
            {
                $user_id=1;//Pass the userid here
                $checkbox = $_POST['printtype'];
                for($i=0;$i<count($checkbox);$i++){
                    $ding = $checkbox[$i];
          $data['catil'] = $this->excel_import_model->selectprint($ding);


                }}

        $this->load->model('excel_import_model');

        $this->load->view('printconsignment',$data);

        }



}

and finally my model is like below:

    public function selectprint($catil) {
                $this->db->select('*');
                $this->db->where("id", $catil);
                $this->db->from('fileupload');
             $query = $this->db->get();
             $result = $query->result();
             return $result;

    }

when i try to pass one checkbox value, its successfully passing to the next page, but when i try to select multiple checkbox, its not happening, any one value is being displayed in the next page, can anyone please tell me what is wrong here, thanks in advance




multiple check boxes to enable/disable just one selector in javascript

I am trying to make a selector available, only if a check box, or more than one are checked. The selector should go back to being disabled if the user unchecks all the checkboxes.

I was trying to implement my solution from this response (that it works perfect for one checkbox paired with any other selector) ; however, when I implement it like this:

$(document).ready(function(){
  var enable_sel = function(){
    $("#pizza_kind").prop("disabled", !$(":checkbox").prop("checked"));
  };

  enable_sel();
  $(":checkbox").change(enable_sel);

}); 
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<form>
  <input type="checkbox" id="p1" name="p1">
  <input type="checkbox" id="p2" name="p2">
  <input type="checkbox" id="p3" name="p3">

  <select name="pizza_kind" id="pizza_kind">
    <option>(choose one)</option>
    <option>"Hawaian"</option>
    <option>"Peperonni"</option>
    <option>"Another"</option>
  </select>
</form>

I got the selector disabled, but it seems that is only reacting to the first checkbox, not the rest of them.

I couldn't make this work in the javascript/html snippet, don't know why.

I am currently using Flask and jquery 3.6.0

What am I doing wrong?




vuejs post checkbox empty data or full data

I am trying to make a checkbox with vue js, so that the method is not written. I want the checkbox to be false in the first place, the next step is that when the checkbox is posted, I want "opening_balance" to be sent as an empty array. or vice versa, if the checkbox is checked, I want it to appear in "opening_balance" when the data is posted.

For example: POST No Checkbox

opening_balance: {}

POST Checked

opening_balance: {date: "2021-08-30", net_total: "1000.00", currency: "USD"}
new Vue({
    el: '#app',
    data() {
        return {
            attributes: {
                opening_balance: {
                    net_total: 0,
                    date: new Date(),
                    currency: USD,
                },
            }
        }
    }
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>

<div id="app" style="padding: 1rem;">
<div class="d-flex">
    <input class="form-check-input" type="checkbox" value="false" @click="attributes.opening_balance" v-model="attributes.opening_balance">
    <label class="form-check-label"><b> opening balance</b></label>
</div>
<div v-if="attributes.opening_balance">
    <input type="text" id="Detaylari" class="form-control" v-model="attributes.opening_balance.date">
    <input type="text" class="form-control" v-model="attributes.opening_balance.net_total">
    <input type="text" class="form-control" v-model="attributes.opening_balance.currency">
</div>
</div>



pure javascript table checkbox filter

Table filter value with checkbox

I want to match all checkboxes conditions.

Problem : when uncheck and checked again. it compared last value

example: I uncheck robot and re-check james It should not display robot

enter image description here

What I need #

enter image description here

function filter(event, filterCol) {
  let element = event.target;
  let condt1 = document.getElementsByClassName(filterCol);
  var table = document.getElementById("listingTable");
      
    for (let i = 0; i < condt1.length; i++) {
      if (condt1[i].innerHTML.toLocaleUpperCase() == element.value.toLocaleUpperCase()) {
        if (element.checked == true) {
           condt1[i].parentElement.closest('tr').style = "display:table-row"

        } else {
           condt1[i].parentElement.closest('tr').style = "display:none"
        }
      }

  }
}

document.querySelectorAll('.option1').forEach(input => input.addEventListener('input', ()=>filter(event,"check1")));
document.querySelectorAll('.option3').forEach(input => input.addEventListener('input', ()=>filter(event,"check3")));
<div id="input">
<label>Filter Name </label><br>
<label>Adison<input class="option1" type="checkbox" value="Adison" checked/></label>
<label>James<input class="option1" type="checkbox" value="James" checked/></label><br><br>

<label>Filter Race </label><br>
<label>human<input class="option3" type="checkbox" value="human" checked/></label>
<label>robot<input class="option3" type="checkbox" value="robot" checked/></label>
</div><br>


<table id="listingTable">
  <tr>
    <th>Name</th>
    <th>Country</th>
    <th>Race</th>
  </tr>
  <tr>
    <td class="check1">Adison</td>
    <td >Sweden</td>
    <td class="check3">robot</td>
  </tr>
   <tr>
    <td class="check1">Adison</td>
    <td >UK</td>
    <td class="check3">human</td>
  </tr>
   <tr>
    <td class="check1">James</td>
    <td >Sweden</td>
    <td class="check3">human</td>
  </tr>
   <tr>
    <td class="check1">James</td>
    <td>Germany</td>
    <td class="check3">robot</td>
  </tr>
   <tr>
    <td class="check1">Adison</td>
    <td>Italy</td>
    <td class="check3">robot</td>
  </tr>
 
</table>

Or I should modified filter function. Can anyone advise with my code ?

Thank.




HTML keep checkbox checked after form submit

I have some checkboxes in my code, that activate input fields after getting checked. For default they are disabled, so that the user chooses, wich input field to activate and so wich filter to activate or not. After the submit of the form the checkbox is always disabled again. Does anybody know how to keep them acitvated after submit, but also make them disabled by default.

<div>
    <input type="checkbox" onclick="var input = document.getElementById('Filter');   if(this.checked){ input.disabled = false; input.focus();}else{input.disabled=true;}" />
    <span class="text-white">Filter</span>
    <input id="Filter" name="Filter" disabled="disabled" />
</div>



lundi 30 août 2021

How to remove empty spaces in JS var?

How can I remove empty space in the var con_str after I join the push value?

HTML

<input type="checkbox" id="chckBox1" onchange="fnTest(this);" /> <a class="ref"> Banana </a>
<input type="checkbox" id="chckBox2" onchange="fnTest(this);" /> <a class="ref"> Apple </a>
<input type="checkbox" id="chckBox3" onchange="fnTest(this);" /> <a class="ref"> Orange </a>

<input type="button" id="testABC" onclick="submit()" value="OK" />

JS

function fnTest(check) 
{
    $(check).is(':checked')
}

function submit() 
{
    var values = [];
    $("input[type=checkbox]:checked").each(function(){
        values.push($(this).next("").text());
    });

    var con_str = "https://www.url-abc.com/"+values.join();
    window.open(con_str.trim());
}

This is the output that I've right now if I select all three checkboxes.

https://www.url-abc.com/%20Banana%20,%20Apple%20,%20Orange

The output that I wanted

https://www.url-abc.com/Banana,Apple,Orange

I tried added con_str.trim(). But it didn't work.

Here's the fiddle, https://jsfiddle.net/izzatz/yx7bn59r/7/




Python (tkinter) getting which checkbuttons are checked?

I'm trying to build a python app where we can make our working schedules. I want to be able to press 2 checkbuttons per employee and to export the ones that are checked into a CSV file. The way i have set up the code right now i'm generating the Checkbuttons in for loops, so i can't give them individual names/values. is there still a way i can see which ones are pressed?

(the variable "times" contains a list of all the available times, starting at 14:00 and ending at 23:00)

#building UI
master = Tk()
emplindex = 1
timeindex = 1
for i in times:
    timelabel = Label(master, text=" " + i + " ").grid(row=0, column=timeindex)
    timeindex +=1
for i in employees:
    namelabel = Label(master, text=i[1]).grid(row=emplindex, column=0)
    timeindex = 1
    for i in times:
        CB =  Checkbutton(master).grid(row=emplindex,column=timeindex)
        timeindex +=1
    emplindex +=1
buildbutton = ttk.Button(master, text = "BUILD SCHEDULE", command=lambda: buttonclicked()).grid(row=100)
def buttonclicked():
    selected = CB
master.mainloop()

This is what the ui outputs




Bookmarklet to actually click on checkboxes?

I have a page where on one side I have several different objects and on the other a checkbox grid, the same for everyone, but values are customized for each object.
Obj A can have box 1 selected and 2 unselected,
Obj B can have box 1 unselected and 2 selected
but the Grid scheme itself is the same for all the objects.

I need to be able to copy the checkboxes values from one specific object onto another object and save my work on server side.
I created a pure JS bookmarklet that saves into the sessionStorage the actual values of 'checked' of a Checkbox Grid:

javascript: var test = []; 
   var check = document.getElementsByClassName("CheckboxGrid");  
   for (var i = 0; i < check.length; i++)   {    
                      test.push(check[i].checked);}  
   sessionStorage.setItem('val', JSON.stringify(test));

And a second bookmarklet that I use on the same page to copy the values of the Checkbox Grid:

javascript: var gridValues = sessionStorage.getItem('val'); //returns an array of Char
   var i = 0; 
   var y = 0; 
   var checkboxes = document.getElementsByClassName("CheckboxGrid");

   while (y<checkboxes.length) 
   {     
        if (gridValues[i] == 't')
                     {checkboxes[y].checked=true; y++; i++;}
        else if (gridValues[i] == 'f')
                     {checkboxes[y].checked=false; y++; i++;}
        else     {i++;}
   }

The code 'works', meaning that on the screen I see the exact copy of the first Grid on the second one; the problem is that it looks like the 2nd bookmarklet is just changing the 'look' of the boxes, and not actually manipulating them.
In fact, when I save or click on a checkbox everything goes back as it was before bookmarklets actions.

Am I doing something wrong? Is it actually possible to have a bookmarklet click on a checkbox and keep its changes on the page even after later user-input (e.g. clicking on another box)?

Thanks to all




Symfony form EntityType checkbox

I'm attempting to create an admin user edit page based off the default user entity/form/repository that includes being able to select the roles for that user.

I created a UserRoles entity/repository to hold all the different roles. And have the following changes to the default UserFormType. It works fine to read the list of roles from UserRoles, and it saves the selected checkboxes to the User entity.

I just haven't been able to get the saved roles from the entity to show as checked in my form.

My code for 'choice_attr' is obviously wrong, but I've included it for some of my debug code. I'm hoping I'm just using the wrong parameter.

<?php

namespace App\Form;

class UserFormType extends AbstractType {

    public function buildForm(FormBuilderInterface $builder, array $options) {
        //var_dump($options);die;
        $builder
                ->add('email', EmailType::class, ['required' => true])
                ->add('plainPassword', PasswordType::class, [ ... ],
                ])
                ->add('firstName', TextType::class, ['required' => true])
                ->add('lastName', TextType::class, ['required' => true])

                ->add('roles', EntityType::class, [
                        'class' => \App\Entity\UserRoles::class,
                        'choice_label' => 'role',

                        'choice_attr' => function ($val, $key, $index) {
                            var_dump($val);
                            var_dump($key);
                            var_dump($index); die;

                            return ($key==1) ? ['checked' => true] : ['checked' => false];
                        },
                        'multiple' => true,
                        'expanded' => true,
                        'data' => null
                    ])
                
                ->add('save', SubmitType::class, ['label' => 'Save'])
        ;

        $builder->get('roles')
            ->addModelTransformer(new CallbackTransformer(
                function ($transform) {
                    return $transform;
                },
                function ($reverseTransform) {
                    $ret = array();

                    foreach($reverseTransform as $obj)
                    {
                        $ret[] = $obj->getRole();
                    }
                    return $ret;
                }
            ))
        ;

        $builder->getForm();
    }

    public function configureOptions(OptionsResolver $resolver) {
        $resolver->setDefaults([
            'data_class' => User::class,
        ]);
    }

}




How to access and change Spinners and Checkboxes in a ListView in Android Studio

I am creating a smart house and in the edit page I need to preload the spinner and checkboxes with the values that the user inputed before. I cant seem to access them. they are in a listview with an array adapter. Is there a different way to access them?

the code where i am trying to access the spinner:

 ArrayAdapter arScenarioOn = new ArrayAdapter(this, R.layout.layout_dropdown_add,ComboPage.options.toArray());
    
        programAdapter = new ComboAddAdapter(this, Items.area,Items.progImag, isChecked,arScenarioOn);
        applianceListview.setAdapter(programAdapter);
    
    
        groupNameTil.getEditText().setText(name);
    
    
       for (int i = 0; i < programAdapter.getCount(); i++) {
            Spinner d = programAdapter.getView(i,null,applianceListview).findViewById(R.id.spinner_scenario);
            TextView dview = programAdapter.getView(i,null,applianceListview).findViewById(R.id.textView_title_group);
            dview.setText("I win");
           //applianceListview.getChildAt(i).findViewById(R.id.spinner_scenario);
           d.setSelection(2);
        }

Code for the single item in list view:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:visibility="visible"
    android:descendantFocusability="blocksDescendants"
    tools:visibility="visible"
    >

    <ImageView
        android:id="@+id/imageView_group"
        android:layout_width="68dp"
        android:layout_height="64dp"
        android:layout_margin="10dp"
        android:src="@drawable/picture_lightbuldyellow" />

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="74dp"
        android:orientation="horizontal">


        <TextView
            android:id="@+id/textView_title_group"
            android:layout_width="77dp"
            android:layout_height="48dp"
            android:layout_marginStart="16dp"
            android:layout_marginLeft="16dp"
            android:paddingTop="20dp"
            android:text="@string/title"
            android:textSize="20sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <Spinner
            android:id="@+id/spinner_scenario"
            android:layout_width="117dp"
            android:layout_height="match_parent"
            android:layout_marginTop="22dp"
            android:layout_marginEnd="15dp"

            android:layout_marginRight="15dp"
            android:textSize="8sp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@+id/checkBox"
            app:layout_constraintTop_toTopOf="parent" />

        <CheckBox
            android:id="@+id/checkBox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:layout_weight="2"
            android:outlineAmbientShadowColor="@color/green"
            android:outlineSpotShadowColor="@color/green"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />


    </androidx.constraintlayout.widget.ConstraintLayout>


</LinearLayout>



dimanche 29 août 2021

Python - Check Box Status Program

I'm trying to make a program that scans PDFs downloaded from a website with selectable text and highlights specific discrepancies. I can make it work for specific "bad words" and "good words" but I am stuck on how to make it find missing check boxes. They are no longer interactive fields in PDF form: enter image description here

Here is my code for everything else so far:

import os

import fitz

source_folder = r"C:\Users\Sserb\Desktop\Test Files"
list_files = os.listdir(source_folder)

good_terms = ["trend", "decrease", "increase"]
bad_terms = ["school", "academic", "homework"]  # words that should be in every pdf file (not every page)

pdf_files = [x for x in list_files if x.endswith(".pdf")]

highlight_summary = []

good_term_summary = []

for file_name in pdf_files:
    # READ IN PDF
    full_filename = os.path.join(source_folder, file_name)
    doc = fitz.open(full_filename)

    good_terms_not_found = good_terms.copy()

    list_hl_pages = []
    for page_num, page in enumerate(doc, 1):

        # SEARCH
        for text in bad_terms:
            text_instances = page.search_for(text)

            # HIGHLIGHT
            for inst in text_instances:
                highlight = page.addHighlightAnnot(inst)
                highlight.update()
                if page_num not in list_hl_pages:
                    list_hl_pages.append(page_num)

        # Search for good terms- all must be found
        words_found = []
        for good_word in good_terms_not_found:
            text_instances = page.search_for(good_word)
            if text_instances:
                words_found.append(good_word)

        for word in words_found:
            good_terms_not_found.remove(word)

    highlight_summary.append([file_name, list_hl_pages.copy()])
    if good_terms_not_found:
        good_term_summary.append([file_name, good_terms_not_found.copy()])

    # OUTPUT
    if list_hl_pages:
        out_file = file_name.replace(".pdf", "-errors.pdf")
        doc.save(os.path.join(source_folder, "output", out_file), garbage=4, deflate=True, clean=True)
    else:
        doc.close()

#print(highlight_summary)
print(good_term_summary)
output_folder=r"C:\Users\Sserb\Desktop\Test Files\output"
new = os.path.join(output_folder,'outputfile.txt')
file = open(new, 'w')
value = str(good_term_summary) + '\n'
file.write(value)
file.close()



samedi 28 août 2021

How can I exclude a certain checkbox class from a jQuery filter if another class's checkbox is already checked?

I'm brand new to coding and have no idea what I'm doing. I feel like I'm not very good at explaining things, either, so I'm sorry if this post is a bit hard to understand. Hopefully looking at the code itself makes more sense.

Basically, I have a list that can be filtered. Each list item contains multiple classes. I also have checkboxes to display each individual class.

However, there are a couple of classes that overlap in terms of list items they apply to but are not exactly the same.

Say, for example, somebody wants to look for things in Class A, but not include things in Class D. If Class A is checked, it will automatically display all list items that Class D also applies to.

What I would like to do is make it so that if Class A is checked, you have the option to also exclude Class D from your search, so that overlapping data can be displayed. Vice versa applies too (ie if Class D is checked, have an option to exclude Class A).

I want the exclusion of classes to be an option, not the default state. Some users may be interested in looking at both Class A and Class D, others may only want one.

<div class="options">
  <label><input type="radio" name="operation" value="union" id="op-union" checked>A or B</label>
  <label><input type="radio" name="operation" value="intersection" id="op-inter">A and B</label>
</div>

<div class="categories">
<span class="category"><input type="checkbox" value="classa" id="cat-classa"><label for="cat-classa">Class A</label></span>
<span class="category"><input type="checkbox" value="classb" id="cat-classb"><label for="cat-classb">Class B</label></span>
<span class="category"><input type="checkbox" value="classc" id="cat-classc"><label for="cat-classc">Class C</label></span>
<span class="category"><input type="checkbox" value="classd" id="cat-classd"><label for="cat-classd">Class D</label></span>
<span class="category"><input type="checkbox" value="classe" id="cat-classe"><label for="cat-classe">Class E</label></span>
<span class="category"><input type="checkbox" value="classf" id="cat-classf"><label for="cat-classf">Class F</label></span>
</div>

<div class="container"> 
<ul>
<div class="filterDiv classa classd"><li>List 1</li></div>
<div class="filterDiv classa classe"><li>List 2</li></div>
<div class="filterDiv classb classd classe"><li>List 3</li></div>
<div class="filterDiv classc classf">List 4</li></div>
<div class="filterDiv classb classd classf">List 5</li></div>
</ul>
</div>

Given the nature of the list, any combination of class and type is possible. Typically, there is only one class, but on occasion there are two. In the actual list, I have far more than just three classes attached to one list item, too.

Script:

<script>
var checkboxes = document.querySelectorAll(".categories input");
for(var i = 0; i < checkboxes.length; i++) {
  checkboxes[i].addEventListener("change", filter);
}
var radios = document.getElementsByName("operation");
for(var i = 0; i < radios.length; i++) {
  radios[i].addEventListener("change", filter);
}
filter();
function filter() {
  var i, j;

  // Choose an operation
  var operation = document.getElementById("op-union").checked ? "union" : "intersection";

  // Get the selected categories
  var checkboxes = document.querySelectorAll(".categories input");
  var categories = [];
  var c;
  for(i = 0; i < checkboxes.length; i++) {
    if(checkboxes[i].checked) {
      c = checkboxes[i].value;
      categories.push(c);
    }
  }

  // Apply the filter
  var items = document.querySelectorAll(".filterDiv");
  var item, show;
  for(i = 0; i < items.length; i++) {
    item = items[i];
    if(categories.length == 0) {
      show = true;
    } else if(operation == "union") {
      // Union: Only one of the categories needs to exist
      show = false;
      for(j = 0; j < categories.length; j++) {
        if(item.classList.contains(categories[j])) {
          show = true;
          break;
        }
      }
    } else {
      // Intersection: All of the categories must apply
      show = true;
      for(j = 0; j < categories.length; j++) {
        if(!item.classList.contains(categories[j])) {
          show = false;
          break;
        }
      }
    }

    if(show) {
      item.classList.add("show");
    } else {
      item.classList.remove("show");
    }
  }
}
</script>

Thanks heaps in advance to anyone who helps! Once again I apologise for the wording, I'm new to this and still figuring my way around it all. Any attempts are much appreciated.




Adding a CheckBox column to an existing TableView

I recently wanted to add a CheckBox column to an existing TableView. To study the problem in isolation, I started with Example 13-6 Creating a Table and Adding Data to It. I added a BooleanProperty and accessors to the Person model class, and I added a new TableColumn with a CheckBoxTableCell as the cell factory. As shown in the image, I see a CheckBox on each row. Although all values are true, none are checked; the checkboxes are live, but setActive() is never called. Recent questions on this topic suggest that I'm missing something; I'd welcome any insight.

image

import javafx.application.Application;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.CheckBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;

/**
 * Example 13-6 Creating a Table and Adding Data to It
 * https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/table-view.htm#CJAGAAEE
 */
public class TableViewSample extends Application {

    private final TableView<Person> table = new TableView<>();
    private final ObservableList<Person> data
        = FXCollections.observableArrayList(
            new Person("Jacob", "Smith", "jacob.smith@example.com"),
            new Person("Isabella", "Johnson", "isabella.johnson@example.com"),
            new Person("Ethan", "Williams", "ethan.williams@example.com"),
            new Person("Emma", "Jones", "emma.jones@example.com"),
            new Person("Michael", "Brown", "michael.brown@example.com")
        );

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        stage.setTitle("Table View Sample");
        stage.setWidth(600);
        stage.setHeight(400);

        final Label label = new Label("Address Book");
        label.setFont(new Font("Arial", 20));

        table.setEditable(true);

        TableColumn<Person, Boolean> active = new TableColumn<>("Active");
        active.setCellValueFactory(new PropertyValueFactory<>("active"));
        active.setCellFactory(CheckBoxTableCell.forTableColumn(active));

        TableColumn<Person, String> firstName = new TableColumn<>("First Name");
        firstName.setCellValueFactory(new PropertyValueFactory<>("firstName"));

        TableColumn<Person, String> lastName = new TableColumn<>("Last Name");
        lastName.setCellValueFactory(new PropertyValueFactory<>("lastName"));

        TableColumn<Person, String> email = new TableColumn<>("Email");
        email.setCellValueFactory(new PropertyValueFactory<>("email"));

        table.setItems(data);
        table.getColumns().addAll(active, firstName, lastName, email);

        final VBox vbox = new VBox();
        vbox.setSpacing(5);
        vbox.setPadding(new Insets(8));
        vbox.getChildren().addAll(label, table);

        stage.setScene(new Scene(vbox));
        stage.show();
    }

    public static class Person {

        private final BooleanProperty active;
        private final StringProperty firstName;
        private final StringProperty lastName;
        private final StringProperty email;

        private Person(String fName, String lName, String email) {
            this.active = new SimpleBooleanProperty(true);
            this.firstName = new SimpleStringProperty(fName);
            this.lastName = new SimpleStringProperty(lName);
            this.email = new SimpleStringProperty(email);
        }

        public boolean getActive() {
            return active.get();
        }

        public void setActive(boolean b) {
            active.set(b);
        }

        public String getFirstName() {
            return firstName.get();
        }

        public void setFirstName(String s) {
            firstName.set(s);
        }

        public String getLastName() {
            return lastName.get();
        }

        public void setLastName(String s) {
            lastName.set(s);
        }

        public String getEmail() {
            return email.get();
        }

        public void setEmail(String s) {
            email.set(s);
        }
    }
}



Google forms - Multiple choice OR checkbox - other regular expression

This is not a RegEx building question. Is there an option to add RegEx validation to the "other" option in either the multiple choice or the checkbox question type? In other words, users would be able to select a set option OR they would be allowed to add their own option ("other"). This own option should meet the regex. I cannot find such an option via the form design tool but was wondering if this is possible via the script. Thanks




Checkbox Shopify

We have a Page in Shopify with Images. Some of the Images have a lizens and some have Not a lizens… But know when the Image with the lizens is in the Shopping Card… Theo must have a Checkbox with „i have agree the lizens“… but only the Images with a lizens… Can you help me please ? We use the theme:“Mobilia“ thank you all




vendredi 27 août 2021

checkbox detection without opencv

Is there any way to detect checkbox in an image? OpenCV can be used but task is only to detect checkboxes, their positions and if they are checked or not. Any light weight open source application?




Extjs checkbox boxLabel color not changing

I have a checkbox along with a boxLabel and a textarea as shown below:

xtype: 'container',
items: [{
    {
      xtype: 'textarea',
      scrollY: true,
      screenX: true,
      height: 130,
      minHeight: 80,
      top: 10,
      width: 650,
      id: 'testDisplay',
      name: 'testDisplay',
      itemId: 'testDisplay',
      bind: {
         value: some text
      },
      listeners: {
         afterrender: function(cmp) {
            textAreaComp = me.down('#testDisplay');
            textAreaComp.setValue(someInfo);
            const myCheckBox = this.up('container').getComponent('testDisplayChkbox');
            this.el.down('textarea').dom.onscroll = function () {
               if (this.scrollHeight <= (this.scrollTop + this.offsetHeight)) {
                   myCheckBox.setDisabled(false);
                   myCheckBox.el.setStyle('color',red);
               }
            };
         }
      },
    },
    {
        xtype: 'checkboxfield',
        name: 'testDisplayChkbox',
        id: 'testDisplayChkbox',
        itemId: 'testDisplayChkbox',
        checked: false,
        boxLabel: someLabel,
    }
]

I am looking to get the outline of the checkbox and the text color of the boxLabel to change between two colors based when the text area is scrolled to the bottom. I have tried to use cls as well as setting the color dynamically as shown above but cannot get to change the colors of either the checkbox or the boxLabel. Any suggestions on how to get this to work?




Jquery .Change() doesnt change on click

I have two checkboxes with labels, and attached each one jQuery change() handler to the display:none, checkboxes via their ids. If I click on the label to change the "checked" status of the checkboxes the event fires every time, but doesn't change the status every time.

You can close the opened div by clicking outside, pressing esc or the close element ( X ). every time the checked status is changed back to "false" so that it should change to "checked" on the next click.

You can see, that the event fires by seeing that the console.log is showing the checked status of the checkboxes on each click. But only every second click the value changes?

function close_explain_box(event) {
  let close_cont = event.data.close_cont;
  if ($(event.target).closest(close_cont).length) {
    return;
  } else if (!$(event.target).closest(close_cont).length || event.which === 27) {
    infomark_checkbox_all.prop("checked", false);
    close_cont.css("display", "none");
    gesamt_product_cont.removeClass("lessopa");
    document_var.off('click keyup', close_explain_box);
  }
}

const gesamt_product_cont = $(".contain_me");
const document_var = $(document);

if ($(".explain_box").length) {
  let close_cont_array = $(".explain_box");
  var infomark_checkbox_all = $("#infomark #infomark_ts");
  close_cont_array.each(function(index) {
    if (close_cont_array[index].classList.contains("exp_pers")) {
      var close_cont = $(".exp_pers");
      var infomark_checkbox = $("#infomark");
    } else if (close_cont_array[index].classList.contains("exp_konfmain")) {
      var close_cont = $(".exp_konfmain");
      var infomark_checkbox = $("#infomark_ts");
    }

    infomark_checkbox.change(function(event) {
      console.log(infomark_checkbox.is(":checked"));
      if (infomark_checkbox.is(":checked")) {
        close_cont.css("display", "flex");
        if (!gesamt_product_cont.hasClass("lessopa")) {
          gesamt_product_cont.addClass("lessopa");
        }
        document_var.on('click keyup', {
          close_cont: close_cont
        }, close_explain_box);
      } else if (!infomark_checkbox.is(":checked")) {
        infomark_checkbox_all.prop("checked", false);
        close_cont.css("display", "none");
        gesamt_product_cont.removeClass("lessopa");
        document_var.off('click keyup', close_explain_box);
      }

    });
    index++;
  });

  $(".close").click(function() {
    infomark_checkbox_all.prop("checked", false);
    close_cont_array.css("display", "none");
    gesamt_product_cont.removeClass("lessopa");
    document_var.off('click keyup', close_explain_box);
    console.log(infomark_checkbox_all.is(":checked"));
  });
}

var infomark_checkbox_all = $("#infomark #infomark_ts");
.infomark_checkbox {
  display: none;
}

.contain_me {
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.infomark {
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid black;
}

.infomark:hover {
  background: black;
  color: white;
}

.explain_box {
  display: none;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 10%;
  width: 50%;
  height: auto;
  z-index: 10000;
  transition: all 0.35s;
  padding: 2.5rem;
  border: 1px solid #ccc;
  border-radius: 0;
  background: white;
  box-shadow: 0px 1px 10px 0px #434242;
}

.closeline1,
.closeline2 {
  height: 12.5%;
  background: black;
  border-radius: 2px;
  display: block;
  transition: 0.5s;
  transform-origin: left;
}

.closeline1 {
  transform: rotate(45deg);
}

.closeline2 {
  transform: rotate(-45deg);
}

.close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2rem;
  height: 2.1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: flex-start;
  cursor: pointer;
  z-index: 110000;
}

.closeline1,
.closeline2 {
  width: 25px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="contain_me">
  <input class="infomark_checkbox" id="infomark_ts" type="checkbox" name="infomark" value="">
  <label class="infomark" for="infomark_ts">&#63; 1</label>
</div>

<div class="contain_me">
  <input class="infomark_checkbox" id="infomark" type="checkbox" name="infomark" value="">
  <label class="infomark" for="infomark">&#63; 2</label>
</div>

<div class="explain_box exp_pers">
  <p>blablablabal</p>
  <div class="close">
    <span class="closeline1"></span>
    <span class="closeline2"></span>
  </div>
</div>

<div class="explain_box exp_konfmain">
  <p>blablablabal</p>
  <div class="close">
    <span class="closeline1"></span>
    <span class="closeline2"></span>
  </div>
</div>



Highlight empty check boxes on PDF

I have written a code that uses PyMuPDF to go through PDFs in a folder, search for specific words, and highlight them on the document. Now I want to expand that to include check boxes that are missing and highlight those as well. The text and boxes are selectable text - not image files. Is there a specific code I can use to include as a searchable term such as “CHECK_BOX Client” so it knows to highlight the box next to “Client” if it was missed? Thank you in advance!




How to use automatically created checkboxes?

i want to change these values and save these into an array. And afterwards I want to upload it to the Database. And i want to use listener like c# use for example if i select one of them i want to echo the name of that checkbox. Could you help me? Everything works just i cant reach the checkboxes values from javascript or php script. i don't care if javascript or php will be the solution. or do you know how to create checkboxes in javascript?

<?php 
    
    
        require_once('datab.php');
        $obj1= new datab();
        $db = $obj1->database();
        $parancs= 'select * from permissions';
        $result = $obj1->quer($res,$db);
        $checkbox = null;
        $parancs= 'select a.user from datab a, permissions j where a.id = j.id';
        $username = $obj1->quer($res,$db);
        echo '<pre>';
        $id = 0;
        $checkbox = null;
        foreach($result as $row){
            $count = 0;
            foreach($row as $rekord)
            {   
    
                
                if( $count == 0)
                {
    
                    echo $username[$id]['user'];
                }
                else
                {
                    if($rekord == 1)
                    {
                    echo  $checkbox[$id][$count] = "<input type='checkbox' value='' id='$id|$count' name='checkbox[]' onclick='myfunction()' checked >";
                    }
                    else
                    {
                        echo $checkbox[$id][$count] = "<input type='checkbox' value='' id='$id|$count' name='checkbox[]'  onclick='myfunction()' >";
                        
                    }
                }
                $count++;
                
                
            }
            $id++;
            echo '<br/>';
        }
        print_r($checkbox);
        file_put_contents('backup.json', json_encode($checkbox));
    
    ?>
    <!DOCTYPE html>
    <html>
    <body>
    
    <form method="POST" action="">
    
    <input type="submit" value= "Save" id="submit" name="submit" onclick='myfunction()'>
    </form>
    </body>
    </html>
<script>
    //and I'm stucked
    
</script>



Checbox with filter datatable

When I write something in search filter, and click checbox to check all, it checks each row regardless of the filter entered. What should I do to have the checbox check only those rows that follow the written filter, if the filter is written? enter image description here




How do I get the selected Value from dynamically created CheckBox?

I added CheckBox controls dynamically from the database to FlowLayOutPanel. How do I get and store all selected values?

My sample code is here...

private void dynamicCheck()
{
    //throw new NotImplementedException();
    DataSet1TableAdapters.tbl_subjects1TableAdapter ta = 
        new DataSet1TableAdapters.tbl_subjects1TableAdapter();
    DataTable dt = ta.GetData();
    foreach (DataRow row in dt.Rows)
    {
        CheckBox chk = new CheckBox();
        chk.Width = 90;
        chk.Text = row[1].ToString();
        chk.CheckedChanged += new 
                          EventHandler(changeCheck);
        flowLayoutPanel1.Controls.Add(chk);            
    }
}   

private void changeCheck(object sender, EventArgs e)
{
    //throw new NotImplementedException();
    CheckBox chk = sender as CheckBox;
    if (chk.Checked)
    {
        //MessageBox.Show("checked item" + chk.Text);        
    }
}

private void buttonSave_Click(object sender, EventArgs e)
{
}



jeudi 26 août 2021

Google Sheets highlight a column if a checkbox is checked and also matches an input, applied to the whole row

So I don't know what to call this so that explains my title, but I have a solution that works, except I want to have this apply to a row of checks so I dont have to duplicate my conditional formatting for every column. This is for a game called Phasmophobia, and I wanted to make a sheet I can select checkboxes to show potential answers for the game. Here is my example:

Basic View

Highlighted View

My conditional formatting function is =if(($C$3=TRUE)*($C6=$C$2),true,false) So what I want is to check if the checkbox is TRUE, then highlight rows that has the corresponding data in the row. This formula works as intended, my only issue is I want to make this formula work for all the checkboxes in one formula, so I don't have to make 20 conditional formatting, because on top of the current formula I have plans to modify it to have 2 additional conditions to highlight for, for example if the checkbox below the top row is checked, then cross off instead of highlight the same rows from the first formula, and to cross off rows which don't contain the correct information. If this isn't possible I can just suck it up and make the conditional formatting rules manually, but I know this game has intentions to add more things to track and I wanted a simple "paste in and it works" solution.

P.S. I only have it comparing the ($C6=$C$2) because it makes it possible to remove the need to keep the columns all lined up with the checkboxes, but I can remove that in place of a "istext($c6)" check.

Link to a copy of my sheet: https://docs.google.com/spreadsheets/d/1I1be4O6BH4S0HscRsY-1NFPOyVm_8F7zr642Bbu28Qg/edit?usp=sharing




Extjs checkbox and textarea - how to disable the checkbox on scroll behavior of the textarea?

I have a text area that displays some text with a vertical scroll bar on the right and a checkbox below the text area as in the code below:

xtype: 'container',
items: [{
    {
        xtype: 'textarea',
        scrollY: true,
        screenX: true,
        height: 130,
        minHeight: 80,
        top: 10,
        width: 650,
        id: 'testDisplay',
        name: 'testDisplay',
        itemId: 'testDisplay',
        bind: {
            value: some text
        },
        listeners: {
            afterrender: function(cmp) {
                textAreaComp = me.down('#testDisplay');
                textAreaComp.setValue(someInfo);
            }
        },
    }, 
    {
        xtype: 'checkboxfield',
        name: 'testDisplayChkbox',
        id: 'testDisplayChkbox',
        itemId: 'testDisplayChkbox',
        checked: false,
        boxLabel: someLabel,
    }
}]

I am looking to disable the checkbox at first and then enable it after scrolling to the end of the text area located above the checkbox. How can this be achieved?




How to disable checkbox if condition is true using jQuery?

console.logI have tried to disable checkbox like

 var t8 =283.50;
 var t9 = 283.50;
        

 if (t8 == t9) {
   $('.checkBoxClass:input([value=' + t11 + ')').attr('disabled', true);
 }

Condition is working but the checkbox is not getting disabled.

trtoggle += 
    "<tr><td class='invoicedate_check'>" + t6 + 
    "</td><td class='invoiceno_check'>" + t7 + 
    "</td><td style='text-align: right;' class='invoiceamt_check'>" + t8 + 
    "</td><td  style='text-align: right;' class=''>" + t9 + 
    "</td><td  style='text-align: right;' class=''>" + balance + 
    "</td><td class='checkBoxtd" + t11 + 
    "'><input type='checkbox' class='checkBoxClass checkBoxClassse" + t11 + 
    "' id='checkbox"+t11+"' name='myTextEditBox[]' value='" + t11 + 
    "'/> Select</td></tr>";

$(".tableinvoice_proj").last().append(trtoggle);

Here is my full function code:

$('#projectname_add').on('change', function() {
        $(".projectname_add_TextBox").val($(".projectname_add option:selected").html());
          var projectname_add = $('.projectname_add').val();
          var getID_comp = $('#getID_comp').val();
          //alert(getID_comp)
          $('#tableproject').find('tbody').remove();
          $('#tableinvoice_proj').find('tbody').remove();
          $('#myprojdisplay_new').find('tbody').remove();
          $('#myprojdisplaylatest').find('tbody').remove();
          if(projectname_add !== "list_all_projects"){
        $.ajax({
            url: base_url + "index.php/welcome/list_a_projects_invoice/",
           // url: base_url + "index.php/welcome/invoice_allList/",
            type: "POST",
            data: {
                "id": projectname_add
            },
            success: function(data) {
                var new_data = JSON.parse(data);
                console.log(new_data)
                
                if(new_data == "No Records Found"){ //no invoice for this project
                     $('#myprojdisplay_new').hide();
                     $('#tableproject').hide();
                     $('#myprojdisplaylatest').hide();
                }else{
                    $('#myprojdisplay_new').show();
                    $('#myprojdisplaylatest').show();
                    $('#tableproject').show();
                }
                
                for (var i = 0; i < new_data.projectinvoicesection.length; i++) {
                    var sl = i +1;
                        
                    //alert(t6)                 
                    var t1 = new_data.projectinvoicesection[i]['parent'].project_amount;
                    var t2 = new_data.projectinvoicesection[i]['parent'].particulars;       
                    var t3 = new_data.projectinvoicesection[i]['parent'].project_ID;        
                    var t4 = new_data.projectinvoicesection[i]['parent'].project_title;     
                    var t5 = new_data.projectinvoicesection[i]['parent'].type;      
                    var t56 = new_data.projectinvoicesection[i]['parent'].period_type;      
                    
                    var object = new_data.projectinvoicesection[i]['child'];
                     
                
                var tr = "<tr data-toggle='collapse' data-target='#demo" + t3 + "' style='background-color: #BBDDDD;color: black;' class='accordion-toggle'><td>"+ sl+"</td><td>"+ t4+"</td><td style='text-align: right;'>"+t1+"</td><td style='white-space: nowrap;'>" + t5 + " " + t56 + "</td><td><button class='open-button-project-edit btn' data-toggle='modal' data-backdrop='static' data-keyboard='false' data-target='#exampleModal_2' onclick='openForm3(" + t3 + ")' style='color: #fff;background-color: #398439;border-color: #255625;'>EDIT</button></td></tr><tr><td colspan='6' class='hiddenRow'><div class='accordian-bodyproj collapse' id='demo" + t3 + "'> <table id='tableinvoice_proj' class='tableinvoice_proj' style='font-size: 14px; border-collapse:collapse;width: 745px; table-layout: fixed;'><thead style='background-color: #86af49;'><tr><th>Invoice Date</th><th>Invoice Number</th><th>Invoice Amount</th><th>Received Amount</th><th>Balance</th><th>Generate Receipt</th></tr></thead><tbody></tbody></table>";
    
                 
                 $("#tableproject").append(tr);
                
              
               $("#tableproject").append('</div></td></tr>');
              
                if( !object || object.length < 1)
                {
                    var trtoggle = `<tr ><td style='text-align:center;' colspan='6' > No records found!</td></tr>`;
                } else
                {
                    var trtoggle = '';  
                for (var property in object) {
                        
                    var t6 = format(object[property].invoice_date);
                    var t7 = object[property].invoice_no;       
                    var t8 = object[property].invoice_amount;           
                    //var t9 = object[property].received_Amt;   
                    var t9 = object[property].totalreceiptamt;   //received amount
                    var t11 = object[property].invoice_ID;  
                    var t10 = object[property].proje_ID;    //invoice table's project id
                    
                    
                    if (t9 == '0.00'){
                        
                    var receiveornot = 'Yet to receive';
                    var balance = object[property].invoice_amount;  
                    
                    }
                    else{
                        var receiveornot = object[property].totalreceiptamt;    
                        var balance = parseFloat(object[property].invoice_amount - object[property].totalreceiptamt).toFixed(2);
                    }
                    
                    
                    
                    
                //  trtoggle += "<tr><td class='invoicedate_check'>" + t6 + "</td><td class='invoiceno_check'>" + t7 + "</td><td style='text-align: right;' class='invoiceamt_check'>" + t8 + "</td><td  style='text-align: right;' class=''>" + t9 + "</td><td  style='text-align: right;' class=''>" + balance + "</td><td class='checkBoxtd" + t11 + "'><input type='checkbox'  class='checkBoxClass checkBoxClassse" + t11 + "' id='checkbox"+t11+"' name='myTextEditBox[]' value='" + t11 + "'/> Select</td></tr>";
                


        trtoggle += 
    "<tr><td class='invoicedate_check'>" + t6 + 
    "</td><td class='invoiceno_check'>" + t7 + 
    "</td><td style='text-align: right;' class='invoiceamt_check'>" + t8 + 
    "</td><td  style='text-align: right;' class=''>" + t9 + 
    "</td><td  style='text-align: right;' class=''>" + balance + 
    "</td><td class='checkBoxtd" + t11 + 
    "'><input type='checkbox' class='checkBoxClass checkBoxClassse" + t11 + 
    "' id='checkbox"+t11+"' name='myTextEditBox[]' value='" + t11 + 
    "'/> Select</td></tr>";

    
            if (t8 == t9) {
                
                console.log("---");
            //  console.log($('.checkBoxClass:input([value=' + t11 + '])'));
                
                        $('.checkBoxClass:input([value=' + t11 + '])').prop('disabled', true);
                  }
                

       }
            }
                    $(".tableinvoice_proj").last().append(trtoggle);





                }
                
                

            }
        });
        
    
    }
})

The above is the code when dropdown option changed, two tables are displaying.one table for project details inside project details invoice html table will come.Here i need to disable the checkbox based on the if condition




DataGridView checkbox column - pass into an array in C#

I have a Windows form application that is written in C# language. Once, the user selects the checkboxes and click on the button 'add', I need to get the relevant names of all the selected checkboxes into an array. Can someone help me, please?

Here's a screenshot with the DataGridView and button

img




Multiple checkbox results with Ajax instead of button submit

This works on the first checkbox only.

        <input type="checkbox" id="check-filter" name="filter[]" value="<?php echo $filter['filter_id']; ?>" checked="checked" />
        <?php echo $filter['name']; ?>
        <?php } else { ?>
        <input type="checkbox" id="check-filter" name="filter[]" value="<?php echo $filter['filter_id']; ?>" />
        <?php echo $filter['name']; ?>

$('#check-filter').on('click', function() { filter = [];

$('input[name^=\'filter\']:checked').each(function(element) {
    filter.push(this.value);
});

location = '<?php echo $action; ?>&filter=' + filter.join(',');

});




mercredi 25 août 2021

How to use automatically created checkboxes in PHP?

I made checkboxes

<?php
    for($i=0;$i<100;$i++){
    echo '<input type="checkbox">';
    }
    //if you want to add a submit btn at last
    echo '<input type="submit" value="Submit">';
    ?>

How to use these checkboxes? If i want to change the values and save to an array. I have a default array to compare with the new array.(changed values) and if those values have changed i want to use this alert message (Changed successfull).




Why can't my mat checkbox update the correct value?

in my app I'm using a BehaviourSubject which I toggle value to update a MatCheckbox. only problem is that the value doesn't get updated to the correct value, in this StackBlitz the value of isChecked is supposed to get setted to false each time I check the checkbox but the value don't get updated.

I've been looking over internet without seeing an answer to my case




Change checkbox value on click

I have checkbox nested in html elements. I want to target it and manipulates its value when somebody check it. I am trying this

jQuery(document).ready(function() {
  jQuery('#my-form .checkbox-value input').click(function() {
    jQuery('#my-form .checkbox-value input[value=yes]').prop('checked', jQuery(this).prop('checked'));
    jQuery('#my-form .checkbox-value input[value=no]').prop('checked', jQuery(this).prop('checked') === false);
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<form id="my-form">
  <div id="checkbox" class="checkbox-value">
    <label class="form-label forms-label-hide" for="checkbox_item">Checkboxes</label>
    <ul id="checkbox_item">
      <li class="choice-1 depth-1">
        <input type="checkbox" id="checkbox_item_1" name="my-checkbox" value="Want to change this value on dom" />
        <label for="checkbox_item_1">Yes, let me know when you have new blogs to share.</label>
      </li>
    </ul>
  </div>

  <div class="">
    <button type="submit">Submit</button>
  </div>

</form>

When someone click on label or checkbox it should changes values to yes if it is checked and no when it is not checked.




How to pass params through a checkbox tag

I have a simple form with a checkbox. I'm trying to pass a sale_id through the checkbox. However in the controller, the sale_id is not in the params hash.

I have tried different (unsuccessful) ways below:

<%= ff.check_box :refund, sale_id: sale.id, checked: true %>

<%= ff.check_box :refund, data: {sale_id: sale.id}, checked: true %>




How can I make a checkbox with curses in python? [closed]

I have to make a simple commandline GUI with curses, and use python to write it. How can I make a simple checkbox? I searched everywhere on the internet, but the only tutorial I found, covering how to make checkboxes with curses, was in C, not in python. Where can I learn how to make things with curses in python at all?

Most of the websites deliver some kind of introduction to curses and some basic stuff, but no advice on how to make specific things like checkboxes.




I m getting 3types of errors1) RenderBox was not laid out2) Failed assertion: line 1930 pos 12: 'hasSize' and Null check operator used on a null value

I am creating a todo app that contains TaskList and Task Tiles and by creating check boxes of task lists and using call back functions I got 3 types of errors.

  1. RenderBox was not laid out 2) Failed assertion: line 1930 pos 12: 'hasSize' 3)Null check operator used on a null value

TaskList class code:

import 'package:flutter/material.dart';
import 'package:todoey_flutter/widgets/TaskTile.dart';


class TaskList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ListView(
      children: <Widget>[
        TaskTile(),
        TaskTile(),
      ],
    );
  }
}

TaskTile code that contains checkbox and callback:

import 'package:flutter/material.dart';
class TaskTile extends StatefulWidget {
  @override
  _TaskTileState createState() => _TaskTileState();
}


class _TaskTileState extends State<TaskTile> {
  bool isChecked= false;


  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(
        'This is my task.',
        style: TextStyle(
        decoration: isChecked ? TextDecoration.lineThrough : null,
    ),),
      trailing: TaskCheckBox(isChecked, (bool checkboxState) {
        setState(() {
          isChecked = checkboxState;
        });
      },
      ),
    );
  }
}

class TaskCheckBox extends StatelessWidget {

  TaskCheckBox (this.checkboxState, this.toggleCheckBoxState);
  final bool checkboxState;
  final Function toggleCheckBoxState;


  @override
  Widget build(BuildContext context) {
    return Checkbox(
      activeColor: Colors.blueAccent,
        value: checkboxState,
        onChanged: toggleCheckBoxState(),
    );
  }
}



Create checkbox tree with lazy loaded children

I m trying to make a tree of checkboxes, i m working with angular and firestore db, the parents and child nodes are related with an id in the children docs, so when implementing this tree i have to load children async on demand from db, the main need is to get all selected children from several parents;
Scenario
1- check a parent so all children (async) get selected and get checked if we expand the parent
2- expand a parent (load children) to check some children
3- get all checked children to perform a task

I'm stuck with this task for a couple of weeks
I need a proposition or a solution that works in this case, PLEASE help.




mardi 24 août 2021

Quasar: Why is QCheckbox selected all in QTable?

I check only one checkbox, but all of the other checkboxs are also checked. It seems like all checkbox has the same index or id, however, there is no way to figure out to fix this issue. I have googled, but could not find the way I am looking for.

Here is the code I wrote

QTable

         <q-table
          id="selection-table"
          :title="undefined"
          :data="curData"
          :columns="columns"
          @request="updateTableData"
          :rows-per-page-options="[10, 20, 30, 40, 50]"
          :pagination.sync="pagination"
          :loading="isLoading"
          row-key="name"
          class="no-shadow q-pa-none"
          selection="multiple"
          :selected.sync="selected"
          :selected-rows-label="getSelectedString"
        >
          <template v-slot:body="props">
            <q-tr :props="props" class="q-pa-none">
              <q-td>
                <q-checkbox v-model="props.selected" />
                
              </q-td>
              <q-td
                v-for="col in props.cols"
                :key="col.name"
                :props="props"
                class="q-pa-none"
                row-key="name"
                :auto-width="col.name == 'title' ? false : true"
              >
                <span v-if="col.name === 'title'">
                  
                </span>
                <span v-else-if="col.name === 'status'">
                  <span v-if="col.value === 0">... </span>
                  <span
                    v-else-if="
                      col.value === 200 && props.goodsStatusCode === 11
                    "
                    >...</span
                  >
                  <span v-else>
                    <span class="text-red">...)</span>
                  </span>
                </span>
                <span v-else>  </span>
              </q-td>
            </q-tr>
          </template>
        </q-table>

Script

<script lang="ts">
import Vue from 'vue';
export default Vue.extend({
  name: 'SelectionTable',
  data() {
    return {
      selected: [],
    };
  },
  methods: {
    getSelectedString() {
      return this.selected.length === 0
        ? ''
        : `${this.selected.length} record${
            this.selected.length > 1 ? 's' : ''
          } `;
    },
  },
});
</script>

Would you let me know what I am missing?




Send checkbox values from View to Action via View Model

I wanna send checkboxes value from View to Action with viewmodel.

Can you help me ؟

I'm sorry about my terrible English




How to enable first checkbox checked on page load and show only the data targeted div and hide others and only one checkbox checked at one time

  1. How to enable First checkbox checked on page load that shows only the data targeted div and hide other divs (i.e. on pageload DIV1 checkbox checked by default and show only DIV1 and hide other DIVS using jQuery first-child). Right now, my first checkbox is showing checked on pageload but it's showing all the the divs on pageload unless physically checked. I just want to show DIV1 checked showing data 1 and hide others on pageload.

  2. How can I have only one Checkbox checked at one time using jQuery please?

  3. When a Checkbox is checked it should hide other DIV and show it's data targeted div only.

This is my code:

$(document).ready(function () {
 $('.my-features').on('click', function () {
    var checkbox = $(this);
    var div = checkbox.data('name');
    if (checkbox.is(':checked')) {

        $('#' + div).show();
    } else {
        $('#' + div).hide();
        $('#' + checkbox.attr('data-name')).hide();
    }
 });    
});

$(document).ready(
 function(){
  $('input:checkbox:first-child').attr('checked',true);
 }
);

<input type="checkbox" data-name="div1" class="my-features" />DIV1
<input type="checkbox" data-name="div2" class="my-features" />DIV2
<input type="checkbox" data-name="div3" class="my-features" />DIV3
<input type="checkbox" data-name="div4" class="my-features" />DIV4
<input type="checkbox" data-name="div5" class="my-features" />DIV5
<input type="checkbox" data-name="div6" class="my-features" />DIV6

<div id="div1">1
</div>
<div id="div2">2
</div>
<div id="div3">3
</div>
<div id="div4">4
</div>
<div id="div5">5
</div>
<div id="div6">6
</div>

I tried my best with the code as I have limited jQuery knowledge. Thanks in advance.




Looking for a google maps checkbox event or somethig like that

I’m still trying to name the problem I’m having :) I’d like people to walk around town and check in at some locations via an app or website. It is supposed to be a city game for tourists. “Check a few of our points of interest and come back to us to verify and you’ll get a small reward :)” I'd like the app to verify that the person was in the places that we have on our map. I was googling for some kind of checkboxes or something like that on google maps but couldn't find anything. Meaby My thinking is bad and I’m looking at it wrong…

Any ideas of how to get started with such a project?

Regards




lundi 23 août 2021

Checkbox: Implode checkbox that have double values

So this is my checkbox

Select all:

<input type="checkbox" id="select_all"/><font size='4'> Select All</font></li>
<? $data=getCheckboxUpdate($id,$month_claim) ?>
    <form name="frmactive" method="post" action="">
    <table border="0">
    <tr><td colspan="5">
         <input class="btn btn-success" name="activate" type="submit" id="activate" value="VERIFY" />
         <input class="btn btn-danger" name="deactivate" type="submit" id="deactivate" value="REJECT" />
    </td>
    </table>

Single checkbox:

    <input name="checkbox[]" type="checkbox" class="checkbox" id="checkbox[]" value="<?php echo $ot['id']; ?>" data-valuetwo="<?php echo $ot['month_claim']; ?>" >

Here my script:

$(document).ready(function(){
    $('#select_all').on('click',function(){
        if(this.checked){
            $('.checkbox').each(function(){
                this.checked = true;
            });
        }else{
             $('.checkbox').each(function(){
                this.checked = false;
            });
        }
    });
    $('.checkbox').on('click',function(){
        if($('.checkbox:checked').length == $('.checkbox').length){
            $('#select_all').prop('checked',true);
        }else{
            $('#select_all').prop('checked',false);
        }
    });
});

And here my function:

function getCheckboxUpdate($id,$month_claim){
    $conn=db();
    if(isset($_POST['checkbox'])){
        $checkbox = $_POST['checkbox'];
        if(isset($_POST['activate'])?$activate = $_POST["activate"]:$deactivate = $_POST["deactivate"])
            $id = "('" . implode( "','", $checkbox ) . "');" ;

            **$month_claim = //How do I get this value from checkbox data-valuetwo**

        $sql="UPDATE aims_ot_approval ap LEFT JOIN aims_ot a ON a.id = ap.ot_id 
              SET ap.verify_status = '".(isset($activate)?'VERIFIED':'REJECTED')."',ap.verify_date=CURRENT_TIMESTAMP 
              WHERE a.month_claim = '$month_claim'
              AND a.staff_record_id IN $id" ;
        $result=$conn->query($sql);
        return $result;
    }
    }

Right now, I only succesfully implode one checkbox value to my function. How do I get the value from checkbox data-valuetwo to my function? Thanks as always




Change td background color based on onclick checbox

I have a javascript where it will change the td background color if I click the checkbox. Below is the javascript

function onload() {
            var tds = document.getElementsByTagName("td");
            for(var i = 0; i < tds.length; i++) {
                tds[i].onclick = 
                                function(td) { 
                                    return function() { 
                                        tdOnclick(td); 
                                    }; 
                                }(tds[i]); 
            }
            var inputs = document.getElementsByTagName("input");
            for(var i = 0; i < inputs.length; i++) {
                inputs[i].onclick = 
                                function(input){ 
                                    return function() { 
                                        inputOnclick(input); 
                                    };
                                }(inputs[i]); 
            }
        }
        function tdOnclick(td) {
            for(var i = 0; i < td.childNodes.length; i++) {
                if(td.childNodes[i].nodeType == 1) {
                    if(td.childNodes[i].nodeName == "INPUT") {
                        if(td.childNodes[i].checked) {
                            td.childNodes[i].checked = false;
                            td.style.backgroundColor = "white";
                        } else {
                            td.childNodes[i].checked = true;
                            td.style.backgroundColor = "#E4E978";
                        }
                    } else {
                        tdOnclick(td.childNodes[i]);
                    }
                }
            }
        }

Here's the td:

<body onload="onload()">
    <td>
       <label><input type="checkbox" class="hidden"></label>
    </td>
</body>

Right now when I click the td, it's working but the color not fill the whole td. You can refer screenshot above:

screenshot of td

I've tried remove the label, but it's still the same.

This is example how I want the color to fill the whole td:

screenshot of td

But I can't find the solution. Hope anyone can help.




Styling a checkbox on webflow and jQuery

I am building a site on webflow and am trying to have a form that has some checkboxes to select several services. I'm trying to add style the checkboxes when they are checked (add a background color and change the color of the label and icon from black to white, but the code jQuery code that I implemented isn't cutting it. I have multiple boxes, so adding unique IDs would make things overly complicated. This is what I have so far:

<script>
$('.checkbox-wrapper').on('click', function() {
    if (!$(this).find('.checkbox-button').is(':checked') {
        $(this).removeClass('active');
        $(this).find('.checkbox-label').removeClass('active');
        $(this).find('.checkbox-icon').removeClass('active');
    } 
    else {
        $(this).addClass('active');
        $(this).find('.checkbox-label').addClass('active');
        $(this).find('.checkbox-icon').addClass('active');
    }
});
</script>



Fillable PDFs created with mpdf are not showing the check boxes

I'm creating fillable PDFs with mPDF but the check boxes, including the box and tick, are not showing in the Chrome print preview and the printed document. In addition, the checkbox in Adobe Acrobat on iOS is not showing the tick. The check boxes work fine on evince and all other widgets work fine.

My setup is as follows: Linux 18.04, Php 7.4, mPDF 8.0.12

Here is the code. It should be noted that I am using the kartik Yii2 extension.

$pdf = new Pdf([
            'mode' => Pdf::MODE_CORE, 
            'format' => Pdf::FORMAT_LETTER, 
            'orientation' => Pdf::ORIENT_PORTRAIT, 
            'destination' => Pdf::DEST_BROWSER, 
            'content' => $html, 
            'cssFile' => '@backend/web/css/fillablepdfs.css',
            // set mPDF properties
            'options' => ['title' => $title, 'useActiveForms' => true, 'CSSselectMedia' => 'print'],
            // call mPDF methods
            'methods' => [
            ]
        ]);

I have seen similar issues on Slackoverflow but none seem to have helped me. Any help would be greatly appreciated.




custom required checkbox to show up when product is in cart (woocommerce checkout)

On my wordpress/woocommerce site I am adding a new product which is a subscription item. When this specific product is in the cart, the checkout page needs to show an additional required checkbox which must be validated before customer can place his order.

Below is the code I have sofar. It makes the checkbox show up correctly when the product is in the cart, BUT it is not required to be checked before you can click on the PAY NOW button.

How can I make the checkbox required?

I have seen this: European GDPR additional checkout validation checkbox in Woocommerce and tried to put that code inside my code (after if ($in_cart) ) but I could not make it work.

Not sure how to proceed to make my below code function:

add_action( 'woocommerce_checkout_terms_and_conditions', 'custom_subscription_checkout_button' );

function custom_subscription_checkout_button() {
   $product_id = 123; // the ONE product where this checkbox needs to show up for
   $in_cart = false;
  
   foreach( WC()->cart->get_cart() as $cart_item ) {
      $product_in_cart = $cart_item['product_id'];
      if ( $product_in_cart === $product_id ) $in_cart = true;
   }
  
   if ( $in_cart ) {
        echo '<p class="form-row validate-required">
                <label class="woocommerce-form__label woocommerce-form__label-for-checkbox checkbox">
                <input type="checkbox" class="woocommerce-form__input woocommerce-form__input-checkbox input-checkbox" name="subscr_terms" />
                    <span class="woocommerce-terms-and-conditions-checkbox-text">I have read and agree to the <a href="#">subscription terms</a></span>&nbsp;<span class="required">*</span>
                </label>
                <input type="hidden" name="terms-field" value="1" />
            </p>';
   } 
}



Check all checkboxes only if condition is met

I have a VBA code that checks/unchecks all checkboxes. However I want the code to check/uncheck only the checkboxes that don't a have 'False' written in them in column E5:E150.

Any help would be appreciated, here is my code :

Sub SelectAllSubSector()

    Dim cBoxSector As CheckBox

    For Each cBoxSector In Worksheets("Input attractivite").CheckBoxes
        If Not Intersect(cBoxSector.TopLeftCell, Range("C5:C150")) Is Nothing Then
            If cBoxSector.Name <> ActiveSheet.CheckBoxes("Check Box 3").Name Then
                cBoxSector.Value = ActiveSheet.CheckBoxes("Check Box 3").Value
            End If
        End If
    Next cBoxSector

End Sub



How can you turn this hover function off?

My checkbox has box-shadow..when I hover on the checkbox. I tried turning it off in every way but still couldn't turn it off. It doesn't show on the inspect. box-shadow and background color doesn't seem to work. This is my checkbox. It has weird blue shadow around the border... Checkbox

.treejs .treejs-node__checked > .treejs-checkbox:before {
    opacity: 1;
    transform: scale(1);
    background-color: #D9368D;
    border-color: hsl(328, 68%, 53%);
    box-shadow: hsl(328, 68%, 53%) inset;
}

Can anyone please help how to turn it off?




How do I change a custom woocommerce checkbox label programmatically?

I have this custom checkbox in the checkout page:

add_action('woocommerce_after_checkout_billing_form', 'checkout_shipping_form_packing_addition', 20);
function checkout_shipping_form_packing_addition()
{
    $domain = 'woocommerce';
    echo '<tr class="packing-select";>' . __('', $domain) . '<td>';

    $chosen   = WC()->session->get('chosen_packing');

    // Add a custom checkbox field
    $variable = <<<XYZ
<html>
<body>
 <p style="font-size:15px; margin-top: -38px; margin-left: 5px; height:auto; border:1px; border-style:solid; border-color:#FF0000; padding: 20px;"><b>Consegna rapida?</b></p>
</body>
</html>
XYZ;
    woocommerce_form_field('chosen_packing', array(
        'type'      => 'checkbox',
        'class'     => array('form-row-wide packing'),
        'label'     => __($variable, 'woocommerce'),
        'required'  => false,
    ), $chosen);

    echo '</td></tr>';
}

I want the label to change when it's checked, so I tried adding this

add_action('woocommerce_after_checkout_billing_form', 'my_custom_checkout_field_process2');
 
function my_custom_checkout_field_process2() {
    global $woocommerce;
 
    // Check if set, if its not set add an error.
    if (isset($_POST['chosen_packing'])){
        
        $_POST['chosen_packing']['label'] = 'no';
    
        }
}

But it doesn't work, and I'm not sure how to proceed exactly. I need the label to change whenever the checkbox is checked.




dimanche 22 août 2021

INNO SETUP Using checkboxes

I'm not familiar with Pascal. I would like to show 10 checkbox before installing. The user can check several checkboxes according to the group of catalogs he wants to install (10 checkboxes = 10 groups of catalogs). These checkboxes have to be tested in FILES section and in CODE section. In FILES section only catalogs of a checked group will be installed. In CODE section, the pictures will be downloaded and unzipped according to the group of catalogs checked.

I made 100 hundred tries but an error occurs because the local variables can not be used in other sections.

[Languages]
Name: fr; MessagesFile: compiler:Languages\French.isl; LicenseFile: C:\Dev\Phi8\licensefr.TXT
Name: en; MessagesFile: compiler:Default.isl; LicenseFile: C:\Dev\Phi8\licenseen.TXT



[Setup]


#include "C:\Dev\Inno Download Plugin\idp.iss"
#include "C:\Dev\Inno Download Plugin\french.iss"



[Tasks]
Name: "chkbInstallFR"; Description: "France"; MinVersion: 0.0,5.0
Name: "chkbInstallMO"; Description: "Monaco, Andorre, TAAF, SPM"; MinVersion: 0.0,5.0
Name: "chkbInstallBELUX"; Description: "Belgique, Luxembourg"; MinVersion: 0.0,5.0
Name: "chkbInstallSUI"; Description: "Suisse, Liechtenstein"; MinVersion: 0.0,5.0
Name: "chkbInstallITA"; Description: "Italie"; MinVersion: 0.0,5.0
Name: "chkbInstallALL"; Description: "Allemagne"; MinVersion: 0.0,5.0
Name: "chkbInstallEURONU"; Description: "Europa, Nations Unies, sepac"; MinVersion: 0.0,5.0
Name: "chkbInstallILE"; Description: "Ile des Antilles, Pacifique, Océan indien"; MinVersion: 0.0,5.0
Name: "chkbInstallAFR"; Description: "Anciennes colonies françaises"; MinVersion: 0.0,5.0
Name: "chkbInstallBUR"; Description: "Bureaux français en Europe, Asie, Moyen-Orient"; MinVersion: 0.0,5.0
  


[Dirs]
Name: {app}\Datas
Name: {app}\Pic
Name: {app}\Pic\AN
Name: {app}\Pic\ANE
Name: {app}\Pic\UNY


[Files]

Source: C:\Sources\Phi\Exe\Datas\UNY_BIN20P.s2db; DestDir: {app}\Datas; Flags: ignoreversion; Check: InstallFR;
Source: C:\Sources\Phi\Exe\Datas\UNY_BIN20D.s2db; DestDir: {app}\datas; Flags: onlyifdoesntexist; Check: InstallFR;


Source: C:\Sources\Phi\Exe\Datas\AN_BIN20P.s2db; DestDir: {app}\Datas; Flags: ignoreversion; Check: InstallMO;
Source: C:\Sources\Phi\Exe\Datas\AN_BIN20D.s2db; DestDir: {app}\datas; Flags: onlyifdoesntexist; Check: InstallMO;

Source: C:\Sources\Phi\Exe\Datas\ANE_BIN20P.s2db; DestDir: {app}\Datas; Flags: ignoreversion; Check: InstallMO;
Source: C:\Sources\Phi\Exe\Datas\ANE_BIN20D.s2db; DestDir: {app}\datas; Flags: onlyifdoesntexist; Check: InstallMO;


Source: C:\Dev\Philatelix8\Install\7za.exe; DestDir: "{app}"; Flags: deleteafterinstall;


[Icons]


[Run]
Filename: {app}\7za.exe; Parameters: "x ""{tmp}UNY.zip"" -o""{app}\Pic\UNY"" * -aoa"; Flags: runascurrentuser;

Filename: {app}\7za.exe; Parameters: "x ""{tmp}AN.zip"" -o""{app}\Pic\AN"" * -aoa"; Flags: runascurrentuser; 
Filename: {app}\7za.exe; Parameters: "x ""{tmp}ANE.zip"" -o""{app}\Pic\ANE"" * -aoa"; Flags: runascurrentuser; 

[INI]


[Code] 
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
var
  chkbInstallFR: TNewCheckBox;
  chkbInstallMO: TNewCheckBox;
  chkbInstallBELUX: TNewCheckBox;
  chkbInstallSUI: TNewCheckBox;
  chkbInstallITA: TNewCheckBox;
  chkbInstallALL: TNewCheckBox;
  chkbInstallEURONU: TNewCheckBox;
  chkbInstallILE: TNewCheckBox;
  chkbInstallAFR: TNewCheckBox;
  chkbInstallBUR: TNewCheckBox;

procedure RedesignWizardForm;
begin
  with WizardForm.SelectTasksLabel do
  begin
    Visible := False;
    Left := ScaleX(392);
  end;

  { chkbInstallFR }
  chkbInstallFR := TNewCheckBox.Create(WizardForm);
  with chkbInstallFR do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(16);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'France';
  end;

  { chkbInstallMO }
  chkbInstallMO := TNewCheckBox.Create(WizardForm);
  with chkbInstallMO do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(40);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Monaco, Andorre, TAAF, SPM';
  end;

  { chkbInstallBELUX }
  chkbInstallBELUX := TNewCheckBox.Create(WizardForm);
  with chkbInstallBELUX do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Belgique et Luxembourg';
  end;

  { chkbInstallSUI }
  chkbInstallSUI := TNewCheckBox.Create(WizardForm);
  with chkbInstallSUI do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Suisse et Liechtenstein';
  end;

  { chkbInstallITA }
  chkbInstallITA := TNewCheckBox.Create(WizardForm);
  with chkbInstallITA do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Italie';
  end;

  { chkbInstallALL }
  chkbInstallALL := TNewCheckBox.Create(WizardForm);
  with chkbInstallALL do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Allemagne';
  end;

  { chkbInstallEURONU }
  chkbInstallEURONU := TNewCheckBox.Create(WizardForm);
  with chkbInstallEURONU do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := False;
    Caption := 'Europa, Nations Unies, sepac';
  end;

  { chkbInstallILE }
  chkbInstallILE := TNewCheckBox.Create(WizardForm);
  with chkbInstallILE do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Iles des antilles, Pacifique et Océan indien';
  end;

  { chkbInstallAFR }
  chkbInstallAFR := TNewCheckBox.Create(WizardForm);
  with chkbInstallAFR do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Colonies françaises en Afrique';
  end;

  { chkbInstallBUR }
  chkbInstallBUR := TNewCheckBox.Create(WizardForm);
  with chkbInstallBUR do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Bureaux français en Europe, Asie, Moyen-Orient';
  end;

  chkbInstallFR.TabOrder := 0;
  chkbInstallMO.TabOrder := 1;
  chkbInstallBELUX.TabOrder := 2;
  chkbInstallSUI.TabOrder := 3;
  chkbInstallITA.TabOrder := 4;
  chkbInstallALL.TabOrder := 5;
  chkbInstallEURONU.TabOrder := 6;
  chkbInstallILE.TabOrder := 7;
  chkbInstallAFR.TabOrder := 8;
  chkbInstallBUR.TabOrder := 9;

{ ReservationBegin }
  // This part is for you. Add your specialized code here.
 
   if chkbInstallFR.checked then 
   begin
      idpAddFile('http://www.philatelix.fr/Divers/PHI/UNY.zip', ExpandConstant('{tmp}UNY.zip'));
   end;

   if chkbInstallMO.checked then 
   begin
      idpAddFile('http://www.philatelix.fr/Divers/PHI/AN.zip', ExpandConstant('{tmp}AN.zip'));
      idpAddFile('http://www.philatelix.fr/Divers/PHI/ANE.zip', ExpandConstant('{tmp}ANE.zip'));
   end;

{ ReservationEnd }
end;
// Don't modify this section. It is generated automatically.
{ RedesignWizardFormEnd } // Don't remove this line!







procedure InitializeWizard;
 begin


{ Download after "Ready" wizard page }
idpDownloadAfter(wpReady);
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
    if CurStep = ssPostInstall then 
    begin
      if chkbInstallFR.checked then 
      begin
        FileCopy(ExpandConstant('{tmp}\UNY.zip'), ExpandConstant('{app}\UNY.zip'), false);
      end;
      if chkbInstallMO.checked then 
      begin
        FileCopy(ExpandConstant('{tmp}\AN.zip'), ExpandConstant('{app}\AN.zip'), false);
        FileCopy(ExpandConstant('{tmp}\ANE.zip'), ExpandConstant('{app}\ANE.zip'), false);
      end;

    end;
end;


function InstallFR: Boolean;
begin
     if chkbInstallFR.checked then 
        begin
          Result := TRUE
        end;
      else
        begin
          Result := FALSE
        end;
      else
end;

function InstallMO: Boolean;
begin
     if chkbInstallMO.checked then 
        begin
          Result := TRUE
        end;
      else
        begin
          Result := FALSE
        end;
end;



Checkbox not unchecking with React

I have an array of matches that I display as a list of rows in my React application. Each row has two athletes, where you can use the checkboxes to predict which one will win. Only one athlete per row can be checked, so I did something like the following to store who's checked, and who's not:

On initial mount I have an empty object in state called predictions. When a user starts interacting with the checkboxes, I use the index of each row as a key to store the id of one of the athletes. This is what it looks like in practice,

{
  0: '12864',
  3: '13333',
  5: '45362',
  ...etc
}

So you can get a better idea of what I'm working on, here is a screenshot.

enter image description here

In my React code, I map through the array of matches like so:

<ul>
{matches &&
    matches.map((match, i) => (
    <li
        key={match.fighter_a_name + match.fighter_b_name}
        className="text-center"
    >
        <Row>
        <Col md={5}>
            <h3>
            {match.fighter_a_name}
            </h3>

            <FormCheck
            type="checkbox"
            id={match.fighter_a_id}
            idx={i}
            onChange={handlePrediction}
            checked={
                parseInt(predictions[i]) === match.fighter_a_id ||
                false
            }
            />
        </Col>

        <Col md={2}>
            {/* <div>{match.weight}</div>
            <div>{match.result}</div>
            <div>{match.time}</div> */}
            <div>{match.rounds}</div>
        </Col>

        <Col md={5}>
            <h3>
            {match.fighter_b_name}
            </h3>

            <FormCheck
            id={match.fighter_b_id}
            idx={i}
            onChange={handlePrediction}
            checked={
                parseInt(predictions[i]) === match.fighter_b_id ||
                false
            }
            />
        </Col>
        </Row>
    </li>
    ))}
</ul>

Each click of the checkbox will execute a function named handlePrediction, that handles the logic of updating the predictions object. It basically checks to see if their is currently a key in the object with the same id value as the checkbox just clicked. If so, it will remove that key from the object, otherwise, it just adds that key to the object, or overrides the current id at that key.

I think I might have some logic issues in here, but for now, here it is.

const handlePrediction = (e) => {
    const id = e.target.id;
    const idx = e.target.getAttribute("idx");

    if (predictions[idx] === id) {
        setPredictions((prev) => {
        delete prev[idx];
        return prev;
        });
    } else {
        setPredictions((prev) => ({ ...prev, [idx]: id }));
    }
};

Now that I gave you the backstory, the problem I am having is that I can't uncheck the athletes in a specific scenario. If I check an athlete in one row, their id is successfully added to the object. Then, if I check the other athlete in the same row, the prior athlete becomes unchecked, and the one just clicked becomes checked, which is what I want.

However, if I check one athlete, and try to uncheck them, the checkbox stays checked permanently. On each click the handlePrediction function seems to handle everything correctly, and adds/removes the user from the object, but without any change in the checkbox.

I have no clue as to why the checkbox won't uncheck. I have created a slimmed down version of this code in a Codepen, which you can tinker around with, it has a full array of match data, so you can see what that looks like too.

P.S. I found something else wrong as well. If you use the codepen, do the following:

  1. Check Sean Strickland
  2. Check Cheyanne Buys
  3. Check Sean Strickland
  4. Check Cheyanne Buys
  5. Check Sean Strickland

After step number 5, you should see Cheyanne Buys become unchecked, which is not supposed to happen. I am definitely doing something wrong here.




How to change default background of checkbox using flask and wtforms?

I don't understand where to add the class name so I can change the background color of the checkbox.

form.py

DOMAINS = ['Bakeries', 'Bars and Pubs', 'Butcher Shops', 'Electronics', 'Fashion', 'Fish Shops',
       'Flowers', 'Furniture', 'Gelaterias and Sweets', 'Pets', 'Other', 'Restaurants and Cafés', 'Sport',
       'Supermarkets', 'Vegetables and Fruits']

class MultiCheckboxField(SelectMultipleField):
widget = widgets.ListWidget(prefix_label=False)
option_widget = widgets.CheckboxInput()

class BuyerForm(FlaskForm):
address = StringField(label='Address', validators=[InputRequired()])
domains_fields = [(x, x) for x in DOMAINS]
domains = MultiCheckboxField(label='Domains', choices=domains_fields)
radius = DecimalRangeField(label='Radius (KM)', default=5, validators=[InputRequired()])
submit = SubmitField(label='Search')

buyer_form.html

            <div class="form-group">
                
                
                    
                
            </div>

I'm looking where to add:

CSS file

.container input:checked ~ .checkmark {
  background-color: #e86875;
}

(I took it from w3school)




Changing woocommerce checkbox label if the checkbox is checked

I made this checkbox in the checkout form of woocommerce (added in the function.php of my child theme):

add_action('woocommerce_after_checkout_billing_form', 'checkout_shipping_form_packing_addition', 20);
function checkout_shipping_form_packing_addition()
{
    $domain = 'woocommerce';
    echo '<tr class="packing-select">' . __('Consegna rapida?', $domain) . '<td>';

    $chosen   = WC()->session->get('chosen_packing');

    // Add a custom checkbox field
    $variable = <<<XYZ
<html>
<body>
 <p style="font-size:15px; margin-top: -36px; margin-left: 23px; height:auto; text-align: center; border:1px; border-style:solid; border-color:#FF0000; padding: 5px;"><b>Consegna rapida? (+5 euro)</b></p>
</body>
</html>
XYZ;
    woocommerce_form_field('chosen_packing', array(
        'type'      => 'checkbox',
        'class'     => array('form-row-wide packing'),
        'label'     => __($variable, 'woocommerce'),
        'required'  => false,
    ), $chosen);

    echo '</td></tr>';
}

I'm trying to make it so when it's checked, the label changes to another sentence but I don't know how to do this, my knowledge of php is kinda low.




How do I select all p tags and make them visible when check box is clicked?

I want all the <p> elements to be displayed when the checkbox is checked and otherwise not displayed.

function change(){
    var nav = document.getElementById("navbar");
    var checkBox = document.getElementById("checkbox");

    if(checkBox.checked == true){
        nav.style.width = "300px";
    } else{
        nav.style.width = "70px";
    }
}
nav{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100px;
    height: 100%;
    transition: 0.3s;
    /* #63. change 2nd to -10px from -6px */
    box-shadow: rgba(136, 165, 191, 0.26) 4px 2px 10px 0px, rgba(255, 255, 255, 0.8) -4px -2px 16px 0px;
}

nav a{
    text-decoration: none;
}

nav li{
    list-style-type: none;
    display: flex;
    color:black;
}

nav p{
    display: none;
}

nav input{
    margin: 10px;
    position: absolute;
    width: 50px;
    height: 50px;
    opacity: 0;
    cursor: pointer;
}

nav input:checked + nav p{
    display: flex;
}
<nav id="navbar">
        <input onclick="change()" type="checkbox" name="" id="checkbox">
        
        <ul>
            <a href="#">
                <li>
                    <p>Home</p>
                </li>
            </a>
            <a href="#">
                <li>
            
                    <p>Summer</p>
                </li>
            </a>
        </ul>
    </nav>