lundi 30 janvier 2023

If there is like 5 checkboxes, I can't uncheck the checkboxes randomly. I can only uncheck one by one

I uncheck the checkboxes, database value got update to 0 from 1. But I can't uncheck the checkboxes randomly. I can only uncheck one by one. Example, there is like 5 results, I can uncheck from 1 to 5 in order. I want to do is uncheck randomly like 5 2 3 1.

Result

  </div>
  <div id="result" style="display: inline-table; margin-left: 150px; margin-top: 22px;">
  <?php
                include("correlationwafer_result.php");
    ?></div>
  <!--div id="result" ></div-->
  <div class="col-sm-10">
   </div>`

Below is correlationwafer_result.php.

<?php 

// ini_set("memory_limit","512M");
include("_dbconn.php");
include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/db_config.inc");
include("//sgewsnant21.amk.st.com/ewsweb/wwwroot/library/common7/standard_defines.inc");
session_start();


$productlotid = isset ($_GET['productlotid'])? $_GET['productlotid']:'';
$zone_enable = isset ($_GET['zone_enable'])? $_GET['zone_enable']:'';
$zone_enablee = isset ($_GET['zone_enablee'])? $_GET['zone_enablee']:'';
//$sql1 = "Update * FROM productdb.tbl_correlationwafer WHERE lotid = '$productlotid' ORDER BY lotid and zone_enable='0'";
$sql = "SELECT * FROM productdb.tbl_correlationwafer WHERE lotid = '$productlotid' ORDER BY product asc, zone asc";
    $result1 = mysqli_query($conn,$sql);
    $row_cnt = mysqli_num_rows($result1);

echo '<table class="table table-bordered table-striped">';
echo "<thead>
    <tr>
    <th>Lot ID</th>
    <th>Product</th>
    <th>Zone</th>
    <th>Enable</th>
    </tr>
    </thead>";
    
    while($row = mysqli_fetch_array($result1))
    {
        echo '<tr>';
        echo '<td>'.$row['lotid'].'</td>';
        echo '<td>'.$row['product'].'</td>';
        echo '<td>'.$row['zone'].'</td>';
        echo "<td><input type='checkbox' name='zone_enable' id='zone_enablee' value='1' onchange='Submitt(\"".$row['zone']."\",\"".$row['lotid']."\")'";
        if($row['zone_enable']==1) {
            echo "checked='checked'"; 
        }
        echo "></td>";
        echo '</tr>';
    }
echo '</table>';

?>


<script type="text/javascript">

function Submitt(zone,productlotid){
    var xhr = new XMLHttpRequest();
    var checkbox = document.getElementById("zone_enablee");
    var value = checkbox.checked ? 1 : 0;
    xhr.open("GET", "test_1.php?zone="+zone+"&value="+value+"&productlotid="+productlotid, true);
    xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xhr.onreadystatechange = function() {
        if (xhr.readyState === 4 && xhr.status === 200) {
            console.log(xhr.responseText);
            if(!checkbox.checked){
                console.log("Record updated successfully");
            }
        }
    }
    xhr.send();
}


</script>

Below is from test_1.php.

<?php 

// ini_set("memory_limit","512M");
include("_dbconn.php");

$zone = $_GET['zone'];
$value = $_GET['value'];
$productlotid = $_GET['productlotid'];

    $sql = "UPDATE productdb.tbl_correlationwafer SET zone_enable = '$value' WHERE lotid = '$productlotid' AND zone = '$zone'";

        if (mysqli_query($conn, $sql)) {
            echo "Record updated successfully";
        } else {
            echo "Error updating record: " . mysqli_error($conn);
        }

echo json_encode($response);
mysqli_close($conn);
?>



dimanche 29 janvier 2023

Checkbox State Persistence before and after form submission

I am new to web developing. Apologies, if this is too simple but could not find the right way to fix this issue.

I have been asked to make a simple form with several checkboxes having a unique name and different values. No problem for that. The issue I am encountering is that I have also been asked that I need to have all the checkboxes checked by default before submission and only to keep the checkboxes that remain checked, checked after the form submission. My code below does not make them all checked by default but save the results after form submission. Even adding the statement checked on the input tag does not change much.

 <form onsubmit="return saveCheckboxValue();">
  <label for="checkbox1">Option 1</label>
  <input type="checkbox" id="checkbox1">
  <br>
  <label for="checkbox2">Option 2</label>
  <input type="checkbox" id="checkbox2">
  <br>
  <label for="checkbox3">Option 3</label>
  <input type="checkbox" id="checkbox3">
  <br>
  <input type="submit" value="Submit">
</form>
   <script>
function saveCheckboxValue() {
  // Get all checkbox elements
  var checkboxes = document.querySelectorAll("input[type='checkbox']");


  for (var i = 0; i < checkboxes.length; i++) {
    if (checkboxes[i].checked) {
      localStorage.setItem(checkboxes[i].id, true);
    } else {
      localStorage.removeItem(checkboxes[i].id);
    }
  }
  return true;
}

window.onload = function() {
  // Get all checkbox elements
  var checkboxes = document.querySelectorAll("input[type='checkbox']");


  for (var i = 0; i < checkboxes.length; i++) {
    checkboxes[i].checked = JSON.parse(localStorage.getItem(checkboxes[i].id)) || false;
  }
};
</script>

I tried to change the value to true

> window.onload = function() {   // Get all checkbox elements   var
> checkboxes = document.querySelectorAll("input[type='checkbox']");
> 
>   for (var i = 0; i < checkboxes.length; i++) {
>     checkboxes[i].checked = JSON.parse(localStorage.getItem(checkboxes[i].id)) || true;   } };

But by doing this, the checkboxes will be checked by default which is good, but if I uncheck some and submit the form, even the unchecked ones will be checked after the form submission.




Yes No check box

I'm new at php the form I'm creating has a Yes No checkbox my form works fine except if you check the Yes box and then check the No box they both stay highlighted. How can I make it so if the Yes box is checked and they check the No box the Yes box is unchecked. If you need my code let me know.

I've tried some of the code for checkbox but being new to php some of it doesn't make any sense.




samedi 28 janvier 2023

How to insert checkbox value in multiple rows in one table PHP [closed]

tengo una tabla con varios campos y con un checkbox. Una vez mostrados todos los campos, se marcan los checkbox que se quieran. Lo que me gustaría es seleccionar todas las filas que tengan el checkbox activado y hacer insert en bbdd y otras cosas. lo he probado de varias maneras pero siempre me sale el mismo mensaje Warning: Undefined array key "selec" in D:\Xampp\htdocs\mf3\ind.php on line 33

Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in D:\Xampp\htdocs\mf3\ind.php:34 Stack trace: #0 {main} thrown in D:\Xampp\htdocs\mf3\ind.php on line 34

La línea 34 es $checkbox = $_POST['selec'];

Llevo varias horas pero no consigo arreglarlo.

Por favor, me puede ayudar alguien?

He recortado el código y lo he dejado mas sencillo para que se vea mejor.

Adjunto código

     <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <link rel="stylesheet" href="css/main.css">
    <script src="css/jquery.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css" />
    <script src="css/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/jquery.dataTables.min.css">
    </style>
    <script type="text/javascript" src="css/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="css/bootstrap-filestyle.min.js"> </script>
    <link href="css/fonts.css" rel="stylesheet">
    <link href="css/main1.css" rel="stylesheet">
    <link href="css/main.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" 
    rel="stylesheet"
        integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
        crossorigin="anonymous">
    <link rel="stylesheet" type="text/css" href="css/crud_hoja.css">
</head>


<body>
    <?php
include('mf_conexion.php');

if (isset($_POST['añadirseleccion'])) {

    $checkbox = $_POST['selec'];
        for ($i = 0; $i < count($checkbox); $i++) {
            $check_id = $checkbox[$i];
            echo "registro " . $check_id;
        }
    }
?>

    <form method="POST" action="">
        <div class="header col-sm-4 mt-0">
            <button type="submit" class="btn btn-primary" style="width:200px" 
            name="añadirseleccion">Submit</button>

            <?php
            $result=$db->query("SELECT * FROM cancion");

            while ($row = $result->fetch_assoc()) { ?>

        </div>

        <table class="table display table-striped table-bordered" id="mitabla"
        style="width:100%">
            <tr class="align-middle ">
                <td class="align-middle"><?php echo $row['artista']; ?></td>
                <td class="align-middle"><?php echo $row['cancion']; ?></td>
                <td class="align-middle"><?php echo $row['cancionId']; ?></td>
                <td class="align-middle text-center size_sel">
                    <input type="checkbox" name="selec[]" id="checkItem" 
                    value="<?php echo $row['cancionId']; ?>">
                </td>
            </tr>
        </table>
    </form>
    <?php }?>

</body>

</html>

Me he mirado todos los casos que he encontrado en stackoverflow pero no he podido solucionarlo. Esperaba poder solucionarlo pero no ha sido posible




.NET MAUI Setting an item SelectedIndex on Page Load is Delayed

When the view appears on the screen there is a short delay setting the values to each control. Is it possible to set the values before the user sees the view?

public UserSettingsView()
{
    InitializeComponent();
    LoadAsync();        
}

private async void LoadAsync()
{
    try
    {
        // Loading data from API
        Languages = await _languageService.GetAsync(AccessToken);
        USStates = await _uSStateService.GetAsync(AccessToken);
        
        // Assigning the list to the ItemSource of each Picker.
        ddlLanguages.ItemsSource = Languages;
        ddlUSStates.ItemsSource = USStates;

        // Getting the user's preferred settings
        var userSettings = await _accountService.GetSettingsAsync(UserID, AccessToken);

        if (userSettings != null)
        {
            // Setting user values to each Picker control. 
            // This is where the delay happens.
            ddlLanguages.SelectedIndex = Languages.FindIndex(x => x.ID == userSettings .LanguageID);
            ddlUSStates.SelectedIndex = USStates.FindIndex(x => x.ID == userSettings .USStateID);
            cbAge.IsChecked = currentSettings.AgeQualified;
        }
    }
    catch
    {
        await DisplayAlert("Oh no!", "Error loading the page", "OK");
    }
}  



jeudi 26 janvier 2023

How can I make a checkbox and a 'details' item tree stary on the same line? HTML

I have a checkbox that will convert to strike-through the text after checked, but I need the text to be an item tree, so far I have accomplished those 2 things, but for the life of me I can't make them to show on the same line and keep the same behavior.

Basically I want it to be like this:

☐ ▶Title of line

But so far it looks like this:

☐‎

▶Title of line

this is what the code looks like:

<!DOCTYPE html>

<html>
<head> 


  <style id="compiled-css" type="text/css">
input[type=checkbox]:checked + label.strikethrough {
   text-decoration:line-through;
}
</style> 
</head> 

 <body> 

  <div class="form-group "> 
   <div class="col-md-5"> 
    <div class="checkbox"> 
     <input type="checkbox" name="packersOff" value="1"> 
     <label class="strikethrough">


    <details>
      <summary>Title of line</summary>
      <ul>
        <li>lvl 1 - thing 1</li>
        <li>lvl 1 - thing 2
      </ul>
    </details>
  </li>

</body>
</html>

Please consider I am new to all this, don't assume I know anything hahaha

I tried using 'nowrap' and followed these articles, to not avail, I don't really know how to use it my situation

https://www.designcise.com/web/tutorial/how-to-force-html-elements-to-stay-on-the-same-line HTML- how to have checkbox and slider on the same line




Value of Provider is not resetting when popping away and coming back

Provider file

class TermsOfServiceProvider extends ChangeNotifier {
  bool _termsOfService = false;

  bool get termsOfService => _termsOfService;

  void termsOfServiceUpdated(bool value) {
    _termsOfService = value;

    notifyListeners();
  }
}

Above is the provider I am using.

CheckoutButton(
                  onPressed:
                      context.watch<TermsOfServiceProvider>().termsOfService
                          ? () {
                              orderAddressBloc.handleFormSubmit(
                                addressFormValues!.value,
                                customerInfoFormValues!.value,
                                useAsBilling: useAsBillingValue.value,
                                optedIn: optIn.value,
                                termsAndConditions: termsConditions.value,
                              );
                            }
                          : null,
                  blocLoadingIndicator: orderAddressBloc.loadingIndicator,
                ),

Above is where I am using the value.

But when I'm popping away from this page and returning the value of termsOfService when coming back is not changing.

I am using a checkbox for handling the data validation so when it is true it is activating a button to be clicked and false the button is inactive.

But when I am clicking for it to be true and navigating away and coming back the checkbox is not ticked but the value is true, setting the button to active when it shouldn't be.

  child: CheckboxListTile(
    value: checkedValue,
    onChanged: (bool? newValue) {
      context
          .read<TermsOfServiceProvider>()
          .termsOfServiceUpdated(newValue!);
      setState(() {
        checkedValue = newValue;
      });
    },

Above is the checkbox code.




mercredi 25 janvier 2023

How create Google Colab checkboxes based on the elements in a list?

I am trying to create checkboxes in Google Collab, and I know that I can use the following code to create a single checkbox:

boolean_checkbox = False #@param {type: "boolean"}

However, I want to create multiple checkboxes based on the elements in a list. I have tried using a for loop and the exec() function to create new variables for each element in the list, like this:

my_list = ["a","b","c","d"]
for i in my_list:
    exec(i+" = True #@param {type: 'boolean'}")

However, this doesn't seem to work. Is there a way to use the exec() function or another method to create multiple checkboxes based on the elements in a list in Google Collab?

I am expecting to see the checkboxes in the form section of the Google Collab notebook, for example:

a ☐
b ☑︎
c ☑︎
d ☐

That the above list of elements is just an example, items will be replaceable.




I want to fill the checkbox on page load if the value is true in the object and when the checkbox is clicked

On loading the page, I load all the notifications that are array of objects. Each object has an isRead value that is a boolean. I want the checkbox in the table to be filled with a check mark if the value isRead = true for a certain object, and if not, to leave the checkbox empty. And when the checkbox is clicked to add/remove its value in the object. If it's not a problem, I'd like you to write me the code because I'm new to vue and Typescript

`This is component : `

const notificationStore  = useNotificationStore() 
let allNotifications = ref<NotificationData[]>([])
let isNotificationRead = ref<boolean>(false)

const isDeleteDialogOpen = ref(false)
const isEditDialogOpen = ref(false)


async function getAllNotifications() {
  try {
    let response = await notificationStore.getNotifications();
    allNotifications.value = response.data.data;
    console.log(allNotifications.value)
  } catch (error) {
    throw error;
  }
  allNotifications.value.forEach((el) => {
        if(el.isRead == true){
          let isNotificationRead = true
        }
        else {
          let isNotificationRead = false
        }
    });
}

getAllNotifications()

</script>

<template>
  <Section>
<template #title>
  Notifications
</template>

<template #body>
    <el-table :data="allNotifications" style="width: 100%">
        <el-table-column label="Updated At">
            <template #default="prop">
                <el-row>
                    <span style="margin-left: 10px"></span>
                  </el-row>
            </template>
        </el-table-column>
        <el-table-column label="Message">
            <template #default="prop">
                <el-row>
                    <span style="margin-left: 10px"></span>
                </el-row>
            </template>
        </el-table-column>
        <el-table-column align="right">
            <template #default="prop">
                <el-checkbox v-model="prop.isNotificationRead"  label="Read" size="small" />
                  <el-icon >
                    <Delete @click="isDeleteDialogOpen = true" />
                  </el-icon>
            </template>
        </el-table-column>
    </el-table>
</template>
  </Section>

  <el-dialog
    v-model="isDeleteDialogOpen"
    title="Are You Sure You Want to Remove This Notification?"
    align-center
    :show-close="false"
  ><template #header="{ close, titleId, titleClass }">
        <h3 >Are You Sure You Want to Remove this Notification?</h3>
    </template>
    <span>This will remove </span>
    <span class="point-out-text"></span>
    <span> from use. This will delete all the items it contains. Are you sure you want to remove it?</span>
    <template #footer>
      <span>
        <el-row justify="end">
          <el-button type="danger" @click="">
            Yes, remove it
          </el-button>
          <el-button @click="isDeleteDialogOpen = false">
            Cancel
          </el-button>
        </el-row>
      </span>
    </template>
  </el-dialog>

  <el-dialog
    v-model="isEditDialogOpen"
    show-close
  >
  <template #header>
  <DialogHeading>
      <template #title>Edit Notification</template>
      <template #subtitle>Edit the existing Notification. Change notification description...</template>
    </DialogHeading>
  </template>
  <template #footer>
      <span>
        <el-row justify="end">
          <el-button type="primary" @click="">
            Save
          </el-button>
          <el-button @click="isEditDialogOpen = false">
            Cancel
          </el-button>
        </el-row>
      </span>
    </template>
  </el-dialog>
</template>

<style scoped>
</style>
`
this is form of data : `data": [
        {
            "id": "6f81bfca-94a5-4cc9-93c0-48fa7d10c866",
            "userId": "8565fe35-e2e8-4d98-8c21-b06688501a63",
            "message": "Category Design you have experience in has been removed.",
            "isRead": true,
            "createdAt": "2023-01-23T09:19:48.305202",
            "updatedAt": "2023-01-24T12:25:18.412720",
            "deletedAt": null
        },
        {
            "id": "20d22d45-553f-4926-a6df-9014a277cd80",
            "userId": "8565fe35-e2e8-4d98-8c21-b06688501a63",
            "message": "Category Backend you have experience in has been removed.",
            "isRead": false,
            "createdAt": "2023-01-23T09:19:16.969621",
            "updatedAt": "2023-01-23T09:19:16.969621",
            "deletedAt": null
        },
        {
            "id": "2cca79e5-1b68-4aad-b8fc-4581e758347d",
            "userId": "8565fe35-e2e8-4d98-8c21-b06688501a63",
            "message": "Category Frontend you have experience in has been removed.",
            "isRead": false,
            "createdAt": "2023-01-23T09:19:11.622430",
            "updatedAt": "2023-01-23T09:19:11.622430",
            "deletedAt": null
        }
    ]`
`

I'm waiting for a good person to help me because I've tried really everything and I don't know how to solve it.




Android: When checkbox is clicked, create chip

My app has a fragment where the user has to select some dances from a list of checkboxes. Let's use "Argentine Tango" as an example. When I select a checkbox, I get the exception "java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.chip.ChipGroup.addView(android.view.View)' on a null object reference"

When I checked on the checkbox, I wanted a chip writing "Argentine Tango" to appear

private CheckBox mTango; private ChipGroup mChipgroup; private ArrayList mChipList = new ArrayList<>();

Then, inside "OnCreateView"

mTango = view.findViewById(R.id.argtango); mTango.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (compoundButton != null) { mChipList.add("Argentine Tango"); displayChipData(mChipList); } else { Toast.makeText(getContext(), "There was an error, try again", Toast.LENGTH_SHORT ); } } });

My displayChipData method:

`private void displayChipData(ArrayList mChipList) { for (String s: mChipList) { Chip chip = (Chip) this.getLayoutInflater().inflate(R.layout.single_chip, null, false); chip.setText(s); mChipgroup.addView(chip); }

}`

When I run the app and check the "Argentine Tango" checkbox, the app closes and I get the following exception

java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.material.chip.ChipGroup.addView(android.view.View)' on a null object reference

Any ideas on how I could fix this? Thanks in advance!




How can we make the checkbox "checked" on returning back to page during pagination which is previously checked in php or laravel?

During Pagination, page reloads and the checked checkbox becomes unchecked on returning back to that page. I expect that the checked checkbox donot disappear in paginating.Is there any way to make checkbox data recovering.It should show the checked row on multiple pages. The code is:

<!DOCTYPE html>
 

    <html lang="en">

 

        <head>
         <meta charset="UTF-8">
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <meta http-equiv="X-UA-Compatible" content="ie=edge">
         <title>Pagination With Ajax</title>
         
         
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
     </head>
    
     <body>



     <div class="row tableOverflow">
         <table class="table table-bordered table-striped" border="1">
             <tr>
                 <th>Check
                 </th>
                 <th>ID</th>
                 <th>Student Name</th>
                 <th>Address</th>
                 <th>Age</th></tr>

                 @foreach ($data as $key => $value)
                 '"
                class="cursor"> --}}
                 <tr>
                     <td>
                         <div id="checkbox-container">
                             <div><input type="checkbox" class="" name="check" id="" autocomplete="off"></div>
                     </div>
                     </td>
                     <td></td>
                     <td></td>
                     <td>  </td>
                     <td></td>
                 </tr>
             @endforeach
         </table>
</div>
     </div>

 </body>

 </html>


        

       




      
 



mardi 24 janvier 2023

How to create a checkbox with a dynamic list of values on googlesheets

I explain my problem to you : I currently have a tab on google sheets with my data which is updated every 4 hours. ( rows are added or removed in no particular order) I would like to create a checkbox column that would act dynamically with the evolution of the list over updates.

Example : If I check the data box for row 20 and the next update I only have 5 rows of data (so 15 rows have been removed), row 20 will be checked when there is no more data at all

I have browsed the internet and seen quite a lot of solutions related to conditional formatting but this does not answer my request unfortunately

I think google app script can be a solution to explore, your help is welcome.




Update Mysql DB from checkboxes

I am trying to give the values ​​0 or 1 to the fields of a database depending on whether the checkbox is checked or not,

but i can't find it and i can't find where is my problem, can you help me?

<?php

//connexion à la base de donnée
include_once "../connexion.php";
 //on récupère le id dans le lien
$id = $_GET['id'];
//requête pour afficher les infos d'un employé
$req = mysqli_query($con , "SELECT * FROM lecteur_badge_statique WHERE id = $id");
$row = mysqli_fetch_assoc($req);


//vérifier que le bouton modifier a bien été cliqué
if(isset($_POST['button'])){
   //extraction des informations envoyé dans des variables par la methode POST
   extract($_POST);
   //verifier que tous les champs ont été remplis
   if(isset($lb1) && $lb2){
       //requête de modification
       $req = mysqli_query($con, "UPDATE lecteur_badge_statique SET lb1 = '$lb1' , lb2 = '$lb2' , lb3 = '$lb3, lb4 = '$lb4, lb5 = '$lb5, lb6 = '$lb6, lb7 = '$lb7, lb8 = '$lb8, lb9 = '$lb9, lb10= '$lb10'
                                                                    lb11 = '$lb11' , lb12 = '$lb12' , lb13 = '$lb13, lb14 = '$lb14, lb15 = '$lb15, lb16 = '$lb16, lb17 = '$lb17, lb18 = '$lb18, lb19 = '$lb19, lb20= '$lb20'
                                                                    lb21 = '$lb21' , lb22 = '$lb22' , lb23 = '$lb23, lb24 = '$lb24, lb25 = '$lb25, lb26 = '$lb26, lb27 = '$lb27, lb28 = '$lb28, lb29 = '$lb29, lb30= '$lb30'
                                                                    lb31 = '$lb31' , lb32 = '$lb32' , lb33 = '$lb33, lb34 = '$lb34, lb35 = '$lb35, lb36 = '$lb36, lb37 = '$lb37, lb38 = '$lb38, lb39 = '$lb39, lb40= '$lb40'
                                                                    lb41 = '$lb41' , lb42 = '$lb42' , lb43 = '$lb43, lb44 = '$lb44, lb45 = '$lb45, lb46 = '$lb46, lb47 = '$lb47, lb48 = '$lb48, lb49 = '$lb49, lb50= '$lb50'
                                    WHERE id = $id");
        $error_message = mysqli_error($con);
        if($error_message == ""){
            echo "No error related to SQL query.";
        }else{
            echo "Query Failed: ".$error_message;
        }
               
       if($req){//si la requête a été effectuée avec succès , on fait une redirection
            header("location: index.php");
        }else {//si non
            $message = "Employé non modifié";
        }

   }else {
       //si non
       $message = "Veuillez remplir tous les champs !";
   }
}

?>
<div class="form">
        <a href="index.php" class="back_btn"><img src="images/back.png"> Retour</a>
        <h2>Modifier l'employé : <?=$row['nom']?> </h2>
        <p class="erreur_message">
           <?php 
              if(isset($message)){
                  echo $message ;
              }
           ?>
        </p>
        <form action="" method="POST">
            <label>lb1</label>
            <input type="checkbox" name="lb1" value="<?=$row['lb1']?>">
            <label>lb2</label>
            <input type="checkbox" name="lb2" value="<?=$row['lb2']?>">
            <label>lb3</label>
            <input type="checkbox" name="lb3" value="<?=$row['lb3']?>">
            <label>lb4</label>
            <input type="checkbox" name="lb4" value="<?=$row['lb4']?>">
            <label>lb5</label>
            <input type="checkbox" name="lb5" value="<?=$row['lb5']?>">
            <label>lb6</label>
            <input type="checkbox" name="lb6" value="<?=$row['lb6']?>">
            <label>lb7</label>
            <input type="checkbox" name="lb7" value="<?=$row['lb7']?>">
            <label>lb8</label>
            <input type="checkbox" name="lb8" value="<?=$row['lb8']?>">
            <label>lb9</label>
            <input type="checkbox" name="lb9" value="<?=$row['lb9']?>">
            <label>lb10</label>
            <input type="checkbox" name="lb10" value="<?=$row['lb10']?>">
            <label>lb11</label>
            <input type="checkbox" name="lb11" value="<?=$row['lb11']?>">
            <label>lb12</label>
            <input type="checkbox" name="lb12" value="<?=$row['lb12']?>">
            <label>lb13</label>
            <input type="checkbox" name="lb13" value="<?=$row['lb13']?>">
            <label>lb14</label>
            <input type="checkbox" name="lb14" value="<?=$row['lb14']?>">
            <label>lb15</label>
            <input type="checkbox" name="lb15" value="<?=$row['lb15']?>">
            <label>lb16</label>
            <input type="checkbox" name="lb16" value="<?=$row['lb16']?>">
            <label>lb17</label>
            <input type="checkbox" name="lb17" value="<?=$row['lb17']?>">
            <label>lb18</label>
            <input type="checkbox" name="lb18" value="<?=$row['lb18']?>">
            <label>lb19</label>
            <input type="checkbox" name="lb19" value="<?=$row['lb19']?>">
            <label>lb20</label>
            <input type="checkbox" name="lb20" value="<?=$row['lb20']?>">
            <label>lb21</label>
            <input type="checkbox" name="lb21" value="<?=$row['lb21']?>">
            <label>lb22</label>
            <input type="checkbox" name="lb22" value="<?=$row['lb22']?>">
            <label>lb23</label>
            <input type="checkbox" name="lb23" value="<?=$row['lb23']?>">
            <label>lb24</label>
            <input type="checkbox" name="lb24" value="<?=$row['lb24']?>">
            <label>lb25</label>
            <input type="checkbox" name="lb25" value="<?=$row['lb25']?>">
            <label>lb26</label>
            <input type="checkbox" name="lb26" value="<?=$row['lb26']?>">
            <label>lb27</label>
            <input type="checkbox" name="lb27" value="<?=$row['lb27']?>">
            <label>lb28</label>
            <input type="checkbox" name="lb28" value="<?=$row['lb28']?>">
            <label>lb29</label>
            <input type="checkbox" name="lb29" value="<?=$row['lb29']?>">
            <label>lb30</label>
            <input type="checkbox" name="lb30" value="<?=$row['lb30']?>">
            <label>lb31</label>
            <input type="checkbox" name="lb31" value="<?=$row['lb31']?>">
            <label>lb32</label>
            <input type="checkbox" name="lb32" value="<?=$row['lb32']?>">
            <label>lb33</label>
            <input type="checkbox" name="lb33" value="<?=$row['lb33']?>">
            <label>lb34</label>
            <input type="checkbox" name="lb34" value="<?=$row['lb34']?>">
            <label>lb35</label>
            <input type="checkbox" name="lb35" value="<?=$row['lb35']?>">
            <label>lb36</label>
            <input type="checkbox" name="lb36" value="<?=$row['lb36']?>">
            <label>lb37</label>
            <input type="checkbox" name="lb37" value="<?=$row['lb37']?>">
            <label>lb38</label>
            <input type="checkbox" name="lb38" value="<?=$row['lb38']?>">
            <label>lb39</label>
            <input type="checkbox" name="lb39" value="<?=$row['lb39']?>">
            <label>lb40</label>
            <input type="checkbox" name="lb40" value="<?=$row['lb40']?>">
            <label>lb41</label>
            <input type="checkbox" name="lb41" value="<?=$row['lb41']?>">
            <label>lb42</label>
            <input type="checkbox" name="lb42" value="<?=$row['lb42']?>">
            <label>lb43</label>
            <input type="checkbox" name="lb43" value="<?=$row['lb43']?>">
            <label>lb44</label>
            <input type="checkbox" name="lb44" value="<?=$row['lb44']?>">
            <label>lb45</label>
            <input type="checkbox" name="lb45" value="<?=$row['lb45']?>">
            <label>lb46</label>
            <input type="checkbox" name="lb46" value="<?=$row['lb46']?>">
            <label>lb47</label>
            <input type="checkbox" name="lb47" value="<?=$row['lb47']?>">
            <label>lb48</label>
            <input type="checkbox" name="lb48" value="<?=$row['lb48']?>">
            <label>lb49</label>
            <input type="checkbox" name="lb49" value="<?=$row['lb49']?>">
            <label>lb50</label>
            <input type="checkbox" name="lb50" value="<?=$row['lb50']?>">

            <input type="submit" value="Modifier" name="button">
        </form>
    </div>

I would like that when the page loads, the database fields that contain the value 1 are checked and then we can check/uncheck the boxes that we want to update to 1 or 0 in the DB.

But already when loading the page the boxes are not checked when they are 1 in the DB.

value="<?=$row['']?> with checkbox doesn't work the same as input type text?

Thanks in advance for your help :)




disable multiple select in checkbox treeview in react

This is my example with treeviewCheckbox. Now this allow multiple checked. I want to check only one at a time.

sample

If there any suggestions please help me.




How can I Mark Initial value of Checkbox Checked of a single row in React tabl

I am getting a list of Products from an API call and I am rendering it through react-table.

  const getItemsList=()=>{
    getAuthorization()
    .get("product/all_products/")
    .then((res) => {
      setProducts(res.data);
   dispatch(setAPIDetailsItemsTable(res.data));

    })
    .catch((err) => {
      console.log("Error in getting products", err);
    });
  }
  useEffect(() => {
    // Get all products
      getItemsList();
  }, []);

I am using redux for state Management

const data = APIDetailsItemsTable

 const columns = React.useMemo(
    () => [
      {
        Header: "Number",
        accessor: "product_id",
      },
      {
        Header: "Item Name",
        accessor: "name",
      },
      {
        Header: "Item Type",
        accessor: "product_type",
      },
      {
        Header: "Status",
        accessor: "status",
        Cell: StatusPill
      }
 ],
    []
  );

return (
 < AddGuideItemstable
            columns={columns}
            data={data == undefined ? [] : data}
            text="Undefined" />
)
          />

Here is the table component. I am working on Editing part. The checkbox can select only one item from the list.

function AddGuideItemstable({ columns, data, text }) {

 const {
   getTableProps,
   getTableBodyProps,
   headerGroups,
   prepareRow,
   page,
   visibleColumns,
   canPreviousPage,
   canNextPage,
   pageOptions,
   pageCount,
   gotoPage,
   nextPage,
   previousPage,
   setPageSize,
   state,
   preGlobalFilteredRows,
   setGlobalFilter,
   selectedFlatRows,
   state: { selectedRowIds }
 } = useTable(
   {
     columns,
     data,
      initialState: {selectedRowIds},
        stateReducer: (newState, action) => {
       if (action.type === "toggleRowSelected") {
         newState.selectedRowIds = {
           [action.id]: true,
           
         }
       }

       return newState;
   },
   },
   useFilters, // useFilters!
   useGlobalFilter,
   useSortBy,
   usePagination, // new
   useRowSelect,
   (hooks) => {
     hooks.visibleColumns.push((columns) => {
       return [
         ...columns,
         {
           Header: "Choose Items",
           id: "selection",
           Cell: ({ row }) => (
             <div className="flex flex-col ml-6">
               <CheckBox {...row.getToggleRowSelectedProps()}/>
             </div>
           ),
   
 //// dispatching selected item ID if changed 

 useEffect(() => {
   let Id = selectedFlatRows.map(
                 d => d.original.id)
   dispatch(setAddGuideItemID(Id))
   console.log("selected row id", Id)
   }, [selectedRowIds]) 


 // Render the UI for your table
 return (
   <>
             <table
               {...getTableProps()}
               className="min-w-full  bg-transparent divide-y divide-gray-200"
             >
               <thead className=" border-b-8 border-white">
                 {headerGroups.map((headerGroup) => (
                   <tr {...headerGroup.getHeaderGroupProps()}>
                     {headerGroup.headers.map((column) => (
                       // Add the sorting props to control sorting. For this example
                       // we can add them into the header props
                       <th
                         scope="col"
                         className="group px-2 py-3 text-center text-sm font-medium text-gray-400 font-Roboto tracking-wider"
                         {...column.getHeaderProps(
                           column.getSortByToggleProps()
                         )}
                       >
                         <div className="flex items-center justify-between">
                           {column.render("Header")}
                           {/* Add a sort direction indicator */}
                           <span>
                             {column.isSorted ? (
                               column.isSortedDesc ? (
                                 <SortDownIcon className="w-4 h-4 text-gray-100" />
                               ) : (
                                 <SortUpIcon className="w-4 h-4 text-gray-100" />
                               )
                             ) : (
                               <SortIcon className="w-4 h-4 text-gray-100 opacity-0 group-hover:opacity-100" />
                             )}
                           </span>
                         </div>
                       </th>
                     ))}
                   </tr>
                 ))}
               </thead>
               <tbody {...getTableBodyProps()} className="bg-white">
                 {page.map((row, index) => {
                   // new
                   prepareRow(row);
                   return (
                     <tr
                       {...row.getRowProps()}
                       className={
                         index % 2 === 0
                           ? "bg-cyan-100 border-b-8 border-white"
                           : "bg-white border-b-8 border-white"
                       }
                     >
                       {row.cells.map((cell) => {
                         return (
                           <td
                             {...cell.getCellProps()}
                             className="pr-1  pl-2 whitespace-nowrap"
                             role="cell"
                           >
                             {cell.column.Cell.name === "defaultRenderer" ? (
                               <div className="text-sm font-semibold text-black">
                                 {cell.render("Cell")}
                               </div>
                             ) : (
                               cell.render("Cell")
                             )}
                           </td>
                         );
                       })}
                     </tr>
                   );
                 })}
               </tbody>
        
    

The checkbox component is as below

import react, { forwardRef, useEffect, useRef, useState } from "react";

export const CheckBox = forwardRef(({ indeterminate, ...rest }, ref) => {
  const defaultRef = useRef();
  const resolvedRef = ref || defaultRef;

  useEffect(() => {
    resolvedRef.current.indeterminate = indeterminate;
  }, [resolvedRef, indeterminate]);

  return (
    <>
      <div class="flex items-center">
        <input
          type="checkbox"
          ref={resolvedRef}
          {...rest}
          id="A3-yes"
          name="A3-confirmation"
          class="opacity-0 absolute h-8 w-8"
        />
    </>
  );
});

I have an ID stored in a state

let ID =  useSelector((state)=> state.guide.AddGuideResID)

What I want to do is if " ID " in the state is equal to the "ID in the products list" then mark the checkbox checked for that row.

I want to achieve like this. I want to mark only single item thats original ID matches the ID in my redux state. Checkbox checked manually




lundi 23 janvier 2023

display the value from portal to odoo model

i was trying to create a checkbox field in my contract module and show it on portal and if customer checks it store that record on in my contract model,

below i have attached all the screenshots, 

thankyou for your help :) 

here is the link for screenshots of the problem

https://imgur.com/a/U5Eklwk

my doubt is to display that value and based on the value it should reflect in my model




Views are changing automaticly in recyclerview - android

I have a recyclerview with 2 views in each item; a textview and a checkbox. i want the user to be able to select the items by long pressing them. the checkboxes are not visible at first but when user longpresses on an item, they get visible and that specefic item's background color changes to black. tehn when user clicks on each item the background changes to black and the item checkbox gets checked. my problem is that when user clicks on one item, some other item backgrounds turn to black as well. here is my adapter:

    `

class RecyclerAdapter(
  val data: ArrayList<MyData>,
  private val context: Context,
  private val activity: MainActivity
) :
  RecyclerView.Adapter<RecyclerAdapter.ViewHolder>() {

  var isInSelection = false

  inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
    val textview = view.findViewById<TextView>(R.id.textView)
    val checkBox = view.findViewById<CheckBox>(R.id.checkbox)
  }

  @SuppressLint("NotifyDataSetChanged")
  override fun onBindViewHolder(holder: ViewHolder, position: Int) {

    holder.textview.text = data[position].name

    holder.checkBox.isVisible = isInSelection
    holder.checkBox.isClickable = isInSelection
    holder.checkBox.isChecked=data[position].isChecked



    holder.textview.setOnLongClickListener {

      if (isInSelection) {
        if (data[position].isChecked) {
          data[position].isChecked = false
          holder.checkBox.performClick()
          holder.textview.setBackgroundColor(ContextCompat.getColor(context,R.color.white))

        } else {
          data[position].isChecked = true
          holder.checkBox.performClick()

          holder.textview.setBackgroundColor(ContextCompat.getColor(context,R.color.black))
        }

      } else {
        isInSelection = true
        data[position].isChecked = true
        notifyDataSetChanged()
      }


      true
    }
    holder.textview.setOnClickListener {

      wasInSelection = isInSelection



      if (isInSelection) {

        if (data[position].isChecked) {
          data[position].isChecked = false
          holder.checkBox.performClick()

          holder.textview.setBackgroundColor(ContextCompat.getColor(context,R.color.white))

        } else {
          data[position].isChecked = true
          holder.checkBox.performClick()

          holder.textview.setBackgroundColor(ContextCompat.getColor(context,R.color.black))

        }


      }


    }

  }
    `

this is the problem: 1

I also tried to set the checkbox ischecked status in the obBindViewHolder outside the clicklisteners using notifyDataSetChanged but in that way i dont get the checkbox toggle animation.




samedi 21 janvier 2023

checkbox checked and explode data in php/mysql

I have a problem with automatically checked values. Using a database, I display the values in a checkbox. Then from the database from another table I want to automatically select them. The data is in the list. I exploded it and checked.

<?php
    require('../config.php');
    $result = mysqli_query($con, "SELECT * FROM pk_skladnik") or die ( mysqli_error($con) );
    while($row = mysqli_fetch_assoc($result)){
        $cal = mysqli_query($con, "SELECT * FROM pk_pizza WHERE IdPizza = 1") or die ( mysqli_error($con) );
        $sol = mysqli_fetch_array($cal);
        $values = $sol['sklad'];
        $array_of_values = explode(", ", $values);
?>
<div class="form-check">
    <?php 
        foreach ($array_of_values as $key){
            $xxx = ($key == $row['skladnik'] ? "checked" : "");
    ?>
    <input class="form-check-input" type="checkbox" value="<?= $row['skladnik']; ?>" <?= $xxx; ?>>
    <?php } ?>
    <label class="form-check-label">
        <?= $row['skladnik']; ?>
    </label>
</div>
<?php } ?>

The current result is, for example, three rows of columns with one value checked in each of them. I want to check these 3 values in one column.




How to code a checkbox that saves changes after refreshing page

I'm trying to change the checkbox data on the server using the patch method, but I can't do it. Give me an advise, please, how to do it correctly. I send a patch request, 202 code is returned. In the preview (developer tools in the browser) it is shown that the changed data is returned from the server, but for some reason the changes do not occur in the db.json file. After I check the checkbox and refresh the page it’s like I never checked the box.

I need an input checkbox that will send a PATCH request to the server to change the TODO-list state.

What I have so far:

async function editCheckbox(id) {
    try {
        checkbox = {
            completed: document.querySelector(`[data-id="${id}"]` + ' input[type="checkbox"]').checked
        }
        await fetch('http://localhost:8080/todo/' + id, {
            method: 'PATCH',
            body: JSON.stringify(checkbox),
            headers: {
                'Content-Type': 'application/json; charset=utf-8',
            },
        });
    } catch (err) {
        console.log(err);
    }
}

And I use a patch on the route:

app.patch("/todo/:id", (req, res) => {
    const { id } = req.params;
    let rawdata = fs.readFileSync("db.json", "utf8");
    let content = JSON.parse(rawdata);
    if (!content.find((i) => i.id == id)) {
        return res.status(404).json({ message: "Todo with that id not found" });
    } else {
        const newTodo = req.body;
        const toWrite = content.map((i) => {
            if (i.id === id) {
                return newTodo;
            }
            return i;
        });

        fs.writeFileSync("db.json", JSON.stringify(toWrite), (err) => {
            if (err) {
                console.error(err);
            }
        });
        res.status(202).json(newTodo);
    }
});



vendredi 20 janvier 2023

How can I click this checkbox? [closed]

When I am not click yet. enter image description here

when i clicked enter image description here

Can you help me how to click this checkbox? enter image description here

I used this code but it is open "Terms and conditions"

driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div/div[3]/div[2]/div/div[1]/label').click()



How can i check this checkbox?

enter image description hereI use this code but nothing appear, who can help me. Thank you

driver.find_element(by = By.XPATH, value = '/html/body/div[1]/div/div/div[3]/div[2]/div/div[1]/label/div').click()




jeudi 19 janvier 2023

Recyclerview item selection with checkbox, creating a new list/recyclerview with checked items in another fragment

I have a RecyclerView showing movie categories fetched with retrofit from an api. Based on it's preferences the user should be able to show (checkbox is checked) or hide (checkbox is unchecked) categories.

Those setting should proceed in Fragment A. After clicking on a save button (or something similar) the check-state of the items/categries should be saved (for next app starts) and the checked items should be passed in a new list that it's showed in a "new" Recyclerview in Fragment B. I read about Recyclerview-Selection, but it's hard to find a clear step by step tutorial, that's following a similar process as I need (and most of them are written in Java, as I am a completely programming beginner it's even harder to understand it).

So I hope that someone here can help me to get on the right way, be able to implement this also for tv-rv and series-rv.

This is my current adapter, nothing special (in my item-layout there is also a checkbox, id = rvCheckBox) but I am not sure on how to implent it here.

class MovieCategoryAdapter : ListAdapter<Data, MovieCategoryAdapter.ViewHolder>(
    MOVIE_CATEGORY_COMPERATOR) {

    inner class ViewHolder(val binding: RvItemMoviecategoryBinding) : RecyclerView.ViewHolder(binding.root) {
        fun bind(category: Data) {
            binding.apply {
                rvItemMoviecategory.text = category.title
            }
        }
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(
            RvItemMoviecategoryBinding.inflate(
                LayoutInflater.from(
                    parent.context
                ),
                parent,
                false
            )
        )
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val moviegenre = getItem(position)!!
        holder.bind(moviegenre)
        holder.binding
    }
    
    companion object {
        private val MOVIE_CATEGORY_COMPERATOR = object : DiffUtil.ItemCallback<Data>() {
            override fun areItemsTheSame(oldItem: Data, newItem: Data) =
                oldItem.id == newItem.id


            override fun areContentsTheSame(oldItem: Data, newItem: Data) =
                oldItem == newItem
        }
    }

}



mat-checkbox is not working while using ng-template in Angular application

Im using Angular Slickgrid to display the data,in that I have noticed that the mat-checkbox is not working while using ng-template.

Current Behavior:

The checkbox is not working while using ng-template in some cases. As per the analysis the mat-checkbox checked class is not added in the DOM. Once inspect the element and added the missing class manually, then it is working fine.

Code format:

<ng-container ngTemplateOutlet]="booleanField" [ngTemplateOutletContext]="{'fieldKey':fieldKey}"></ng-container>

Template:

<ng-template #booleanField let-fieldKey="fieldKey">

<div>

<ng-container [ngTemplateOutlet]="matLabel" [ngTemplateOutletContext]="{'fieldKey':fieldKey}">

<section class="example-section">

<mat-checkbox id="FLD_cspfm_webcommon_lookup_filter_" class="cs-margin-left-to-right" (change)="valueChange(fieldKey,$event, undefined, 0)" [checked]="filterSectionDetail['filterFields'][fieldKey]['fieldValue'][0]"> true </mat-checkbox>

<mat-checkbox id="FLD_cspfm_webcommon_lookup_filter_" class="cs-margin-left-to-right" (change)="valueChange(fieldKey,$event, undefined, 1)" [checked]="filterSectionDetail['filterFields'][fieldKey]['fieldValue'][1]"> false </mat-checkbox>

</section>

</div>

</ng-template>

Expected Behavior:

The checkbox should be work in all cases while using ng-template.

Software Version

  • Angular : 13.3.9
  • Angular-Slickgrid : 4.3.1
  • TypeScript : 4.6.4
  • Operating System : Windows 10
  • Node : 14.18.3
  • NPM : 6.14.8



mercredi 18 janvier 2023

how to hide/show div with primeng checkbox?

Simple question. I am trying to hide/show div in angular depending on the checkbox condition.

Currently, I am using primeng checkbox but my code does not work.. can anyone please advise me?

Here is the code I made:

<home.component.html>

<p-checkbox [(ngModel)]="showMe" [binary]="true"></p-checkbox>

<div *ngIf="showMe"> example </div>

<home.component.ts>

export class HomeComponent implements OnInit {

  showMe: boolean = false;

}

Should I consider using (onChange) in this case?




Do nothing when the first checkbox is selected and then it will add .10 to the original value for every next checkbox selection

I have a group of checkboxes and I want the Original price to stay the same when the 1st checkbox is selected and then add 0.10 to the original price for every following checkbox chosen. This should also reset the original value back to its initial state when none are selected.




lundi 16 janvier 2023

How to uncheck the previous selected mat checkbox based on single check

I'm trying to uncheck a previous selected checkbox based on clicking one new mat checkbox

My HTML:

  <form [formGroup]="deleteform" (submit)="submit()">
    <ul>
      <li *ngFor="let test of getvalue?.food">
        <mat-checkbox [disableRipple]="true" [value]="test.id" [name]="'test.id'"
          aria-label="Value">
        </mat-checkbox>
      </li>
      <mat-checkbox (change)="unCheckAll($event)">None of Above
      </mat-checkbox>
    </ul>
    <button>
      submit <br>
    </button>
  </form>

MY TS:

deleteform: FormGroup;

unCheckAll($event) {
  this.deleteform.reset();
}

So far I tried this but it's not working, Any solution to uncheck previous selected checkbox based on clicking a new checkbox.




How can I store in a String the text of CheckBox's created programatically

I have an Array of Strings String [] products = {"apple", "orange", "banana", "tomato"};

I have created a for loop that runs through the array products and creates a Checkbox and sets for each Checkbox the String of the array in the position that is running in the for loop. Then it adds the checkbox to a Linear Layout.

Once I have created all the checkbox with the different strings from array I need to store in a String the text of the checkboxs that are clicked and checked...

This is my code

    private LinearLayout linearLayout;

    linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
    int i = 0;
    String [] products = {"apple", "orange", "banana", "tomato", "cheese", "ham", "sausages"};

 for (i=0; i<products.length; i++) {
        cb = new CheckBox(getApplicationContext());

        cb.setText(products[i]);
        linearLayout.addView(cb);
    }

//Now i need that when a checkbox is clicked and keeps checked it stores the text value in a concatenated String (concatenates all the checkbox that are clicked)




Excel VBS: multiple Individual Exclusive Checkboxes with data validation (create a Macro with selecting cells to format them) (code is here)

I'm trying to introduce Checkboxes into my personal project Planning, unfortunately normal Checkboxes tend to bug out, so I found this side here and am trying to convert it into a macro to select the rows I want checks at. Specifically the last one that is NOT "Mutually Exclusive" but with data validation. http://www.vbaexpress.com/kb/getarticle.php?kb_id=879

Unfortunately it does not let me make it into a macro like I wanted to and I spent a lot of time trying already. :(

Please Help

I tried to write a SelectionRng. Or searched for a way to write it into a Macro to select it in the Worksheet.

Option Explicit

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

    'Limit Target count to 1
    If Target.Count > 1 Then Exit Sub
    'Isolate Target to a specific range
    If Intersect(Target, Range("Ckboxes")) Is Nothing Then Exit Sub
    'Set Target font to "marlett"
    Target.Font.Name = "marlett"
    'Check value of target
    If Target.Value <> "a" Then
        Target.Value = "a"    'Sets target Value = "a"
        Target.Interior.ColorIndex = 44
        Cancel = True
        Exit Sub
    End If
    If Target.Value = "a" Then
        Target.ClearContents    'Sets target Value = ""
        Target.Interior.ColorIndex = 0
        Cancel = True
        Exit Sub
    End If
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

    'Limit Target count to 1
    If Target.Count > 1 Then Exit Sub
    'Isolate Target to a specific range
    If Intersect(Target, Range("Ckboxes")) Is Nothing Then Exit Sub
    'Select a specific subset of the range "Ckboxes"
    Select Case Target.Address
    Case Else
        'Populate the cell to the right of Target with its status
        If Target.Value = "a" Then
            Target.Offset(0, 6) = "Checked"
        Else:
            Target.Offset(0, 6).Value = "Not Checked"
        End If
    End Select
End Sub



dimanche 15 janvier 2023

react js state value always false

hello im trying to make a array that contain a objects and i want to map this array into two tables :thisis stricture of array:

0
: 
{title: 'uml', agreement: false}
1
: 
{title: 'react', agreement: false}
2
: 
{title: 'laravel', agreement: false}
length
: 
3
[[Prototype]]
: 
Array(0) 

and i have a checkbox that make agreement true or false . but the problem is everytime the agreement is false. i want to send objects to first table if is true and to seconde table if is false but everytime is send to first table with false agreement . this is all of code: some functions is just to show the values of states

import './App.css';
import { useRef, useState } from 'react';

function App() {

  const [modules,setModules]=useState([])
  const [agreement,setAgreement]=useState()
  const [title,setTitle]=useState()
  const checkbox=useRef()

  function handlecheck(){

    setAgreement(checkbox.current.checked)
    
  }
  function handlechange(event){
    setTitle(event.target.value)

  }
  function ajouter(){
    setModules([...modules,{title,agreement}])
    
  }
  function affich(){
    return console.log(modules)
  }


  return (
    <div className="App">
      <section class="container cd-table-container">
        <h2 class="cd-title">Insert Table Record:</h2>
        <input onChange={(event)=>handlechange(event)} type="text" class="cd-search table-filter" data-table="order-table" placeholder="module name" />
        <button className='ajouter' onClick={()=>ajouter()}  >Ajouter</button>
        <button className='ajouter' onClick={()=>affich()}  >affich</button>
        <input type={"checkbox"} ref={checkbox}   onChange={(event)=>handlecheck(event)} />
        <table class="cd-table table">
          <thead>
            <tr>
              <th>modules regionaux</th>
            </tr>
          </thead>

          <tbody>
            {
              modules.map((elm,index)=>{
                if(elm.agreement=true){
                  return (<tr>
                    <td>{elm.title}</td>
                  </tr>)
                }
              })
            }
          </tbody>
        </table>
        <br></br>
        <table class="cd-table table">
          <thead>
            <tr>
              <th>modules non regionaux</th>
            </tr>
          </thead>

          <tbody>
          {
              modules.map((elm,index)=>{
                if(elm.agreement=false){
                  return (<tr>
                    <td>{elm.title}</td>
                  </tr>)
                }
              })
            }
          </tbody>
        </table>
      </section>
    </div>
  );
}

export default App;



samedi 14 janvier 2023

Tkinter: How to default-check the checkbuttons generated by for loops

I try to set the default value for each item as the boolean value of the list, but it is still unchecked.

I have the code piece below. It was created using forloop to generate multiple checkbuttons. In the program I'm trying to implement, there are more of these check buttons. but I've reduced them to five below.

from tkinter import *

class App():
    def __init__(self, root):
        keys = [True, True, False, False, False]
        self.root = root
        for n in range(0, 5):
            self.CheckVar = BooleanVar()
            self.checkbutton = Checkbutton(self.root, text = 'test_' + str(n), variable = self.CheckVar.set(keys[n])).pack()
           
root = Tk()
app = App(root)
root.mainloop()

Or I also tried this way.

        for n in range(0, 5):
            self.CheckVar = BooleanVar(value=keys[n])
            self.checkbutton = Checkbutton(self.root, text = 'test_' + str(n), variable = self.CheckVar).pack()

And then these checkbuttons enable the user to modify the boolean values of the list.




Tkinter (Python) checkbox inside scrollbar

I'm trying to create a scroll full of checkboxes but I'm having 3 problems:

  1. I can't center the scroll sidebar
  2. I can't define a scroll size of my choice
  3. it seems that if the mouse is over the checkboxes the scroll doesn't work and I have to go to an area without checkboxes

This is my code:

    text = tk.Text(self, cursor="arrow")
    vsb = tk.Scrollbar(self, command=text.yview)
    vsb.grid(row=7, column=4, rowspan=2, sticky='nse')
    text.configure(yscrollcommand=vsb.set, width=20)
    text.grid(row=7, column=4, rowspan=2, columnspan=1)
    self.checkbuttons = []
    self.vars = []
    for i in range(20):
      var = tk.IntVar(value=0)
      cb = tk.Checkbutton(text, text="checkbutton #%s" % i, variable=var, onvalue=1, offvalue=0)
      text.window_create("end", window=cb)
      text.insert("end", "\n")
      self.checkbuttons.append(cb)
      self.vars.append(var)

      text.configure(state="disabled")

I'm also open to other solutions but basically I need a scroll with a variable number of checkboxes inside. and I would like the scroll size to be well defined




vendredi 13 janvier 2023

Adding an optional checkbox to a user registration form in wordpress

I would like to add an optional checkbox to a user registration form saying "I want to be included in marketing activities and product updates". I would like to then accordingly register the user preference... is there a way to do that?

Thank you in advance!

So far, I did not find any plugin or able to do so.




How to select the multiple checkbox

I have to select the multiple checkboxes but every time i click the button it takes only once and comes back to button.

 <div class="dropdown-menu mselect" aria-labelledby="dropdownMenuButton">
                                        <div class="dropdown-item " ng-repeat="tagitem in distinctTags">
                                          <div style="margin-right:10px;" ng-click="addRemoveTag(tagitem)" ng-class="isActive(tagitem) ? 'selectedStudent' : 'notSelectedStudent'"></div>
                                          <span class="multi"ng-click="addRemoveTag(tagitem)" ></span>
                                        </div>                                        
                                       </div>
                                    </div>

js

 $scope.addRemoveTag = function(tagitem){
       
        if ($scope.selectedTags.includes(tagitem)){
            $scope.selectedTags = $scope.selectedTags.filter(item => item !== tagitem);
            
            
        }
        else{
            
            $scope.selectedTags.push(tagitem);
            
        }
       
        
    }

i want to select multiple checkbox and send those values to addRemoveTag function




mercredi 11 janvier 2023

Color group buttons in Shiny when clicked

I'm having trouble changing the color of checkboxGroupButton when clicked. There doesn't seem to be any way to do a checkboxGroup in shiny where you can specify the color of the button pre and post click.

The code below will make the boxes change colors but only between white and grey. I want to customize the color it is by default and also when clicked.

              checkboxGroupButtons(
                inputId = "checkboxInput", label = "", 
                choices = c("A", "B", "C", "D"), 
                justified = FALSE, 
                status = "default",
                individual = TRUE,
                direction = "vertical",
                selected = "A",
                checkIcon = list(
                  yes = icon("circle-check", class = "fa-regular"),
                  no = icon("circle", class = "fa-regular")
                )
              )

I included this tag and can get it to change to color orange but I can't get it to change to another color when clicked.

  tags$style(
    HTML(
      "
      .btn.checkbtn {
        font-size: 15px;
        line-height: 1px;
        border-color: #0C3261;
        border-width: 2px;
        background-color: orange;
        margin-bottom: 1px; /*set the margin, so boxes don't overlap*/
      }
      "
    )
  ),




Precheck checkboxes in b-form-checkbox-group (Vue and Bootstrap)

I have an array (a1) that contains all objects that are relevant for this problem and a smaller array (a2) that contains some of those objects. Now, I want to create a checkbox group to edit a2 with the options being all objects of a1. Therefore, I want to precheck all checkboxes within that group that are included in a2 but I can't figure out how to. Can someone help please?

This is where I'm currently at:

<b-form-checkbox-group v-model="a2" class="overflow-auto fixed-height" style="height: 150px">
   <b-form-checkbox
      v-for="o in a1"             
      :value="o.id"
      :key="o.id"
      >
      
   </b-form-checkbox>
</b-form-checkbox-group>

a1, a2 and their objects are retrieved from a database.




How to align contact 7 checkbox +Label to center horizontally on the page?

I cant seem to get the checkbox on the contact 7 form in wordpress to align in the center without turning everything in my form centered. I dont know what im doing wrong so if anyone could point me in the right direction i would be grateful.

<div class="row">
        <div class="col-sm-4">
            <div class="form-group">
                <label for="form_name">First Name *</label><input id="form_name" type="text"     name="name" class="form-control" required="required" data-error="name is required.">
                <div class="help-block with-errors"></div>
             </div>
        </div>
        <div class="col-sm-4">
            <div class="form-group">
                <label for="form_name">Last Name *</label><input id="form_name" type="text" name="surname" class="form-control" required="required" data-error="name is required.">
                <div class="help-block with-errors"></div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="form-group">
                <label for="form_email">Email *</label><input id="form_email" type="email" name="email"  class="form-control" required="required" data-error="Valid email is required.">
                <div class="help-block with-errors"></div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="form-group">
                <label for="form_phone">Phone Number *</label><input id="form_phone" type="tel" name="phone" class="form-control">
                <div class="help-block with-errors"></div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="form-group">
                <label>Preferred Contact Method</label>[text PreferredContactMethod "Email/Phone"]
           </div>
        </div>
        <div class="col-sm-4">
            <div class="form-group">
                <label>Desired Moving Date</label>[date DesiredMovingDate] 
          </div>
        </div>
<div class="mb-12">
             <div class="col-md-12 col-lg-12"> <position:center>
                <label>Desired Unit Type</label>[checkbox DesiredUnitType use_label_element "Studio" " 1-Bedroom  " " 2-Bedroom  " "3-Bedroom" "Penthouse"]

          </div>
       </div>
       
       <div class="col-md-12">
                <label>Message</label>[textarea Message]
<div class="col-md-12">[submit class:btn class:btn-default class:btn-sm "Send"]</div>
    </div>
</div>



JavaScript can't check MDL checkbox [duplicate]

When I click on "Check", only the normal checkbox gets checked and not the MDL one (as shown in the image below). Would someone know why this is happening?

enter image description here

function check() {
  document.getElementById('mdl').checked = true;
  document.getElementById('normal').checked = true;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.blue_grey-deep_purple.min.css" />
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="mdl">
  <input type="checkbox" id="mdl" class="mdl-checkbox__input">  
  <span class="mdl-checkbox__label">MDL</span>
</label>
<input type="checkbox" id="normal" name="normal">
<label for="normal"> Normal</label><br>
<button type="button" class="mdl-button mdl-js-button mdl-button--raised" onclick="check()">Check</button>



lundi 9 janvier 2023

Javascript: How do I append the label textContent after a custom span checkbox?

Looking for some help/knowledge with moving the label text to the right side of the custom checkbox instead of the left.

If you check the CodePen link below you will see that upon adding a new list item that the label text is on the wrong side of the custom checkbox. I added some hard coded list items for reference of what I want it to look like. If you have a solution to this problem please help educate me.

CodePen: Todo List

Desired HTML output

<li class="todo__list--item">
  <input type="checkbox" id="task-1" name="task-1" />
  <label for="task-1" class="todo__label">
    <span class="custom__checkbox"></span>
    Hard code list item #1
  </label>
  <button class="btn-del" type="button">
    <img src="../images/icon-cross.svg" alt="">
  </button>
</li>

JavaScript

const usrInput = document.getElementById('create-new');
const itemCount = document.querySelector('.item-count');

function addToList() {
  const input = document.createElement('input'); 
        input.className = 'input__cb';
        input.id = 'input';
        input.type = 'checkbox';
  const spanCB = document.createElement('span');
        spanCB.className = 'custom__checkbox';
  const label = document.createElement('label');
        label.className = 'todo__label';
        label.setAttribute('for', 'input');
        label.textContent = usrInput.value;
        label.appendChild(spanCB);
  const img = document.createElement('img');
        img.src = 'https://raw.githubusercontent.com/meetjoewarren/learning-center/9b6cbb922ae2c81be98b6a0374bfcd08a0081e98/frontend-mentor/todo-app-main/images/icon-cross.svg';
  const button = document.createElement('button');
        button.className = 'btn-del';
        button.type = 'button';
        button.appendChild(img);
  const listItem = document.createElement('li');
        listItem.className = 'todo__list--item';
        listItem.draggable = 'true';
        listItem.appendChild(input);
        listItem.appendChild(label);
        listItem.appendChild(button);
  const details = document.querySelector('.todo__list--details'); 
  const fragment = new DocumentFragment();
        fragment.appendChild(listItem);
  const list = document.querySelector('.todo__list');
        list.insertBefore(fragment, details);
  itemCount.textContent = document.querySelectorAll('.todo__list--item').length;
  usrInput.value = '';
}

// Add to list on 'Enter' press
usrInput.addEventListener('keydown', e => {
  if (e.code === 'Enter') {
    addToList();
  }
})


// Delete Button
const deleteBtn = document.querySelectorAll('.btn-del');

for (let i = 0; i < deleteBtn.length; i++) {
  deleteBtn[i].addEventListener('click', e => {
    e.target.parentElement.parentElement.remove();
    itemCount.textContent = document.querySelectorAll('.todo__list--item').length;
  })
}

// If checked cross out
// const inputCB = document.querySelectorAll('.input__cb');
// const todoLabel = document.querySelectorAll('.todo__label');
// for (let i = 0; i < todoLabel.length; i++) {
//   if (inputCB == true) {
//     todoLabel[i].classList.add('strikeout');
//   } else {
//     return;
//   }
// }

Also, bonus question... how would I go about observing changes to the list so I can update the remove/delete button function? Mutation Observer? Right now it is only attaching the event listener to the currently hard coded list items.




samedi 7 janvier 2023

How to disable checkboxes in a Checkbox Group imported from dash mantine components (e.g. dmc)?

Dear Stackoverflow Members

I am currently looking for advice on how to disable a Checkbox from the CheckboxGroup so as to prevent multiple selection.

As an illustration, please find below a sample code built:

  dmc.CheckboxGroup(
                      id="checkbox-group",
                      orientation="horizontal",
                      offset="md",
                      mb=10,
                      children=[
                                 dmc.Checkbox(label="LABEL_A", value="lbl_a"),
                                 dmc.Checkbox(label="LABEL_B", value="lbl_b"),
                                 dmc.Checkbox(label="LABEL_C", value="lbl_c"),
                               ],
                   ),

 @app.callback(
                Output("checkbox-group", "children"), Input("checkbox-group", "value"),
              )

 def select(checkbox):

       if "lbl_a" in checkbox:
                return [
                         dmc.Checkbox(label="LABEL_A", value="lbl_a", checked= True),
                         dmc.Checkbox(label="LABEL_B", value="lbl_b", disabled= True),
                         dmc.Checkbox(label="LABEL_C", value="lbl_c", disabled= True),
                       ] 

Thanks in advance.

Best wishes.




Getting checkbox value from database in CodeIgniter and ajax request

I'm trying to get the value of book_active column (ENUM data type) from database. If equals 'Y' checkbox should be checked and if not, checkbox value should be 'N'.

jquery bit:

`  function edit_book(id) {
    /*    var formData = $('#form').serialize();
        console.log('Posting the following: ', formData); */

    save_method = 'update';
    $('#form')[0].reset(); // reset form on modals
    $.ajax({ //Load data from ajax
      url: "<?php echo site_url('book/ajax_edit/') ?>" + id,
      type: "GET",
      dataType: "JSON",
      success: function(data) {
        $('[name="book_id"]').val(data.book_id);
        $('[name="book_isbn"]').val(data.book_isbn);
        $('[name="book_title"]').val(data.book_title);
        $('[name="book_author"]').val(data.book_author);
        $('[name="book_category"]').val(data.book_category);
        $('[name="book_date"]').val(data.book_date);
        $('#modal_form').modal('show'); // show bootstrap modal when loaded complete
        $('.modal-title').text('Edit Book'); // Set title to Bootstrap modal title
        $('#errors').addClass('d-none');
        var date_string = dayjs(data.book_date, "YYYY-MM-DD HH:mm:ss").format("DD.MM.YYYY, HH:mm"); //Format date in form
        $('[name="book_date"]').val(date_string);

        //  $('[name="book_active"]').val(data.book_active);
        if ($('[name="book_active"]').val(data.book_active) == 'Y') {
          $('[name="book_active"]').prop("checked", true).val();
        } else {
          $('[name="book_active"]').prop("checked", false).val();

        }

        /*
              var SlectedList = new Array();
              $("input.form-check:checked").each(function() {
                SlectedList.push($(this).val(data.book_active));
              });


            
                     if ($('[name="book_active"]').val() == 'Y') {
                       $('[name="book_active"]').prop("checked", true);
                     } else {
                       $('[name="book_active"]').prop("checked", false);
                     }


                    
                     if (val(data.book_active) != NULL) {
                       $('[name="book_active"]').prop("checked", true);

                     } else {
                       $('[name="book_active"]').prop("checked", false);
                     }
                     */

      },
      // complete: function() {
      //   alert('ajax completed!');
      // },
      error: function(jqXHR, textStatus, errorThrown) {
        alert('Error get data from ajax');
      }
    })
  }`

input field in html:

`<input name="book_active" id="book_active" type="checkbox" role="switch" class="form-check-input" <?= (isset($book->book_active)) ? set_checkbox('book_active', 'Y', false) : set_checkbox('book_active', 'N', false) ?>>`

I've tried many snippets but I'm stuck. Commented bits don't work.




vendredi 6 janvier 2023

Why does this boolean gives null value? [closed]

booleans giving 2 differents answers

Hi, I would like to know why those 2 booleans give me 2 differents answers ?

                Boolean b1 = CheckBox.getvalue();
                boolean b2 = CheckBox2.getvalue();
                
                System.err.println(b1); // NULL
                System.err.println(b2); // false



Checkbox design bootstrap

I'm trying to get a checkbox to look like this

correct box

what I've tried

                     <div class="col-2">
                            <label for="WitholdingTax">Charge</label>
                            <div class="input-group mb-3">
                                <input type="checkbox" class="form-control" style="height:50px" aria-label="Amount (to the nearest dollar)">
                                <div class="input-group-prepend">
                                    <span class="input-group-text" style="height:50px">0</span>
                                </div>
                                <div class="input-group-append">
                                    <span class="input-group-text" style="height:50px">%</span>
                                </div>
                            </div>
                        </div>

And that looks like this Wrong box




jeudi 5 janvier 2023

React/Redux component with checkboxes does not update when click on checkbox even though I'm returning new state

I've been stuck for a while trying to make the re-render in the checkboxes to work, the variables are being updated but it's just the rendering that doesn't happen.

I'm receiving a response from the backend that contains an object with an array of steps, I'm going to render a checkbox for every step if it's from a specific type. As soon as I received the object, I add in every step a new property value to use it later for checking the checkboxes.

This is my reducer:

export const MyObject = (state: MyObject = defaultState, action: FetchMyObjectAction | UpdateStepsInMyObjectAction) => {
switch (action.type) {
    case "FETCH_MYOBJECT":
        return {
            ...action.payload, // MyObject
            steps: action.payload.steps.map((step) => {
                if (step.control.controlType === "1") { // "1" = checkbox
                    return {
                        ...step,
                        value: step.control.defaultValues[0] === "true" ? true : false, // Adding the property value
                    };
                }
                return step;
            }),
        };
    case "UPDATE_STEPS":
        return {
            ...state,
            steps: state.steps.map((step) => {
                if (step.id === action.payload.stepId) { // if this is the checkbox to update
                    return {
                        ...step,
                        value: action.payload.checked,
                    };
                }
                return step;
            }),
        };
    default:
        return state;
}

This is how I'm rendering the checkboxes:

 for (let step of steps) {
    if (step.control.controlType === "1") {
       controls.push(
            <Checkbox
                label={step.displayName}
                checked={step.value}
                onChange={(_ev, checked) => {
                    callback(step.id, checked);
                }}
                disabled={false}
                className={classNames.checkbox}
            />
        );
    }
}

callback is a function that calls the reducer above for the case "UPDATE_STEPS".

After inspecting the variables I can see that they are being updated properly, it's just that the re-render doesn't happen in the checkboxes, not even the first time I check the box, the check doesn't appear. If I move to a different component and then go back to the component with the checkboxes I can see now the checks. But if I check/uncheck within the same component, nothing happens visually.

As far as I know, I'm returning new objects for every update, so mutability is not happening. Can you see what I'm missing?

Thanks!




How to validate a checkbox is checked or not and then performing some action in Cypress?

<div class="ag-react-container"><div class="text-center"><input type="checkbox" class="" checked=""></div></div>
cy.("#checkbox").then(($ele) => {
   if($ele.next().is(':checked')){
      cy.("#checkbox").next().should("be.checked");
     }
   else {
     cy.("#checkbox").next().find("input").check();
     cy.("#checkbox").next().find("input").should("be.checked");
     }
  });

My problem is the code above is not going into if condition and keeps on executing else condition.

Learning cypress so code can be wrong and would expect correct full code along with some more examples of same if else condition check for buttons, checkboxes or elements.




mercredi 4 janvier 2023

Multiple userform checkbox values

I am trying to take the values passed from a userform that has the following checkbox options and write them to a single concatenated cell.

Scenario Options and Userform Output Cells

Scenario Options and Userform Output Cells

userform

userform

Thank you for your help. Any suggestions would be greatly appreciated. I currently have attempted this, but can only get one option to show up at a time.

Private Sub CheckBox1_Click()

If Me.CheckBox1.Value = True Then
    Me.Frame2.Visible = True
    Sheets("Project Analysis - Summary").Range("D7") = 1
Else
    Me.Frame2.Visible = False
End If

End Sub

Private Sub CheckBox2_Click()

If Me.CheckBox2.Value = True Then
    Me.Frame3.Visible = True
    Sheets("Project Analysis - Summary").Range("D8") = 1
Else
    Me.Frame3.Visible = False
End If

End Sub

Private Sub CheckBox3_Click()

If Me.CheckBox3.Value = True Then
    Me.Frame4.Visible = True
    Sheets("Project Analysis - Summary").Range("D9") = 1
Else
    Me.Frame4.Visible = False
End If

End Sub

Private Sub CheckBox5_Click()

If Me.CheckBox5.Value = True Then
    Me.Frame6.Visible = True
    Sheets("Project Analysis - Summary").Range("D10") = 1
Else
    Me.Frame6.Visible = False
End If

End Sub

Private Sub CheckBox6_Click()

If Me.CheckBox6.Value = True Then
    Me.Frame5.Visible = True
    Sheets("Project Analysis - Summary").Range("D11") = 1
Else
    Me.Frame5.Visible = False
End If

End Sub

Private Sub CommandButton1_Click()

Dim ctrl1 As Control

Set ctrl1 = Nothing
    
For Each ctrl1 In Me.Frame2.Controls
    If TypeName(ctrl1) = "OptionButton" And ctrl1.Value = True Then
        Sheets("Project Analysis - Summary").Range("E7") = ctrl1.Caption
    End If
Next

Dim ctrl2 As Control

Set ctrl2 = Nothing
    
For Each ctrl2 In Me.Frame3.Controls
    If TypeName(ctrl2) = "OptionButton" And ctrl2.Value = True Then
        Sheets("Project Analysis - Summary").Range("E8") = ctrl2.Caption
    End If
Next

Dim ctrl3 As Control

Set ctrl3 = Nothing
    
For Each ctrl3 In Me.Frame4.Controls
    If TypeName(ctrl3) = "OptionButton" And ctrl3.Value = True Then
        Sheets("Project Analysis - Summary").Range("E9") = ctrl3.Caption
    End If
Next

Dim ctrl4 As Control

Set ctrl4 = Nothing
    
For Each ctrl4 In Me.Frame5.Controls
    If TypeName(ctrl4) = "OptionButton" And ctrl4.Value = True Then
        Sheets("Project Analysis - Summary").Range("E10") = ctrl4.Caption
    End If
Next

Dim ctrl5 As Control

Set ctrl5 = Nothing
    
For Each ctrl5 In Me.Frame6.Controls
    If TypeName(ctrl5) = "OptionButton" And ctrl5.Value = True Then
        Sheets("Project Analysis - Summary").Range("E11") = ctrl5.Caption
    End If
Next

End Sub


Private Sub UserForm_Initialize()

Me.Frame2.Visible = False
Me.Frame3.Visible = False
Me.Frame4.Visible = False
Me.Frame5.Visible = False
Me.Frame6.Visible = False
Sheets("Project Analysis - Summary").Range("D7") = ""
Sheets("Project Analysis - Summary").Range("D8") = ""
Sheets("Project Analysis - Summary").Range("D9") = ""
Sheets("Project Analysis - Summary").Range("D10") = ""
Sheets("Project Analysis - Summary").Range("D11") = ""
Sheets("Project Analysis - Summary").Range("E7") = ""
Sheets("Project Analysis - Summary").Range("E8") = ""
Sheets("Project Analysis - Summary").Range("E9") = ""
Sheets("Project Analysis - Summary").Range("E10") = ""
Sheets("Project Analysis - Summary").Range("E11") = ""

End Sub



React native checkbox

I would like to use checkBox in my react nativem mobile app. I'm trying to using this community package :

https://github.com/react-native-checkbox/react-native-checkbox

But I got this error when I'm trying to use it in my app :

ERROR  [Invariant Violation: requireNativeComponent: "RNCCheckbox" was not found in the UIManager.]

I correctly install the package but there is probably another problem.. There is my code :

 <CheckBox
     disabled={false}
     value={selectedItems.includes(item)}
     onValueChange={() => toggleSelection(item)}
 />

If someone could explain me another solutions or explain me where is the problem.




mardi 3 janvier 2023

Checkbox or dropdown with Plotly.JS?

I know that Dash provides checkboxes / dropdowns (via dcc, Dash Core Components, see https://dash.plotly.com/dash-core-components).

But how to create a checkbox in the context of a pure Plotly.JS plot, without dash?




lundi 2 janvier 2023

Setting a future day of repair depending on warranty selection

First of all I'm really new to Web Dev, just learnt basics of JS last week.

I have a project in which I have a VIP status, and 3 warranty types. If the client is VIP -> fixing the issue will take up to 7 days. Then I have 3 types of warranties - None, Regular, Extended. None - up to a month of repair. Regular - up to 3 weeks of repair. Extended - up to 2 weeks of repair.

The solution must include ONLY javascript (no jQuery yet). since the VIP checkbox isn't a part of the warranty selection, I'm having trouble connecting them.

In case my explanation confuses you - if the client is VIP - warranty options should be DISABLED. since it automatically gets a faster service. if VIP checkbox isn't checked - I need to show the time of repair as shown above.

Thanks in advance

 <input type="checkbox" id="isVIP" />VIP?
<select name="warranty" id="warranty">
          <option disabled selected>Select warranty</option>
          <option value="none">None</option>
          <option value="regular">Regular</option>
          <option value="Extended">Extended</option>



Some problems about live data

In sign up fragment, I have term condition part. When you click this text, bottom sheets opens. I click the button that end of the page(Accept Button). I want checkbox in sign up should be clicked.

Repository

  var resultOk = MutableLiveData<Boolean>()
  fun checkResult(){
    resultOk.value = true
}

Sign Up View Model

`
private var _resultOk = MutableLiveData<Boolean>()
val resultOk: LiveData<Boolean>
    get() = _resultOk

Sign Up Fragment

      viewModel.resultOk.observe(viewLifecycleOwner, Observer {
        binding.cbTermsAndCondition.isChecked = it
    })

BottomSheetView Model

  init {
    checkResult()
}

fun checkResult() {
    fireBaseRepository.checkResult()
}

BottomSheet Fragment

     binding.btnTermAccept.setOnClickListener {
        //Constant.result.value = true
        //viewModel.resultOk.value
        viewModel.checkResult()
        dismiss()
    }

Why checkbox is not clicked, when I click "accept button" end of the bottomsheet.