jeudi 4 février 2021

How to enable button after at least one row has been checked in Datatables?

In this test code, I have a button that I want to be disabled if no checkboxes are checked and enabled if at least one checkbox is checked.

The function to do this works but not on data tables. I am trying to make it work on datatables. But its not working with me

This is not my code... This is just to test.

$(document).ready(function() {
  var dataTable = $('#example').dataTable({
    columnDefs: [{
        orderable: false,
        className: 'select-checkbox',
        targets: 0
      },
      {
        "visible": false,
        "searchable": false,
      }
    ],
    select: {
      style: 'multi',
      selector: 'td:first-child'
    },
    order: [
      [1, 'asc']
    ]
  })

  var checkBoxes = $('.select-checkbox');
  checkBoxes.change(function() {
    $('#btnSelectedRows').prop('disabled', checkBoxes.filter(':checked').length < 1);
  });
  $('.select-checkbox').change();

});


<
/script>
<!DOCTYPE html>
<html>

<head>


  <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css">
  <link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables_themeroller.css">
  <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
  <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js"></script>
  <link rel="stylesheet" href="https://cdn.datatables.net/select/1.3.1/css/select.dataTables.min.css">
  <link href='http://codeseven.github.io/toastr/build/toastr.min.css' rel='stylesheet' type="text/css">
  <script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.22/datatables.min.js"></script>
  <script type="text/javascript" src="https://cdn.datatables.net/select/1.3.1/js/dataTables.select.min.js"></script>
  <script src="js/bootstrap.min.js"></script>


</head>

<body>


  <button id="btnSelectedRows" name="btnSelectedRows" data-target="#grnModal" data-toggle="modal" class="btn btn-success btn-s">
                click
                </button>
  <table class="dataTable" id="example">
    <thead>
      <tr>
        <th></th>
        <th>Rendering engine</th>
        <th>Browser</th>
        <th>Platform(s)</th>
        <th>Engine version</th>
        <th>CSS grade</th>
      </tr>
    </thead>
    <tbody>


      <tr>

        <td></td>
        <td>Misc</td>
        <td>Dillo 0.8</td>
        <td>Embedded devices</td>
        <td>-</td>
        <td>X</td>
      </tr>
      <tr>
        <td></td>
        <td>Misc</td>
        <td>Links</td>
        <td>Text only</td>
        <td>-</td>
        <td>X</td>
      </tr>
      <tr>
        <td></td>
        <td>Misc</td>
        <td>Lynx</td>
        <td>Text only</td>
        <td>-</td>
        <td>X</td>
      </tr>
      <tr>
        <td></td>
        <td>Misc</td>
        <td>IE Mobile</td>
        <td>Windows Mobile 6</td>
        <td>-</td>
        <td>C</td>
      </tr>
      <tr>
        <td></td>
        <td>Misc</td>
        <td>PSP browser</td>
        <td>PSP</td>
        <td>-</td>
        <td>C</td>
      </tr>
      <tr>
        <td></td>
        <td>Other browsers</td>
        <td>All others</td>
        <td>-</td>
        <td>-</td>
        <td>U</td>
      </tr>
    </tbody>
  </table>



How to bind ngmodel inside each item in for loop angular 8?

I want deselect the radio button, but after searching alot..I didn't find answer. So I choose the way of making checkbox work as a radio button(only single selection).And it worked fine but when I'm not able to bind ngmodel to checkbox. I want the checkbox like

  • Item1 Id Name
  • Item2 Id Name
  • Item3 Id Name And there are checkbox to check only one from Id and Name



If a Button is selected in one activity in another activity the check box should get tick mark

I have two activities one of the activity there is a button called accept ,if user press the accept button it comes back to the main activity and in the main activity the check box should be tick in kotlin




mercredi 3 février 2021

How to add multiple checkbox selections to my database using php

I have a checkbox input to insert activities into "act" colomn in "blooddonor" table in "sangamdb" database but I can't seem to figure out the right way to insert the multiple choices from my form to my database table. The other elements works fine except this one. My code so far: FORM:(I have other elements. I just mentioned the probleme)

<form role="form" action = "addeddonor.php" method = "post">
<div class="form-group">
                                    <label for="exampleInputEmail1">Activites</label><br>
                                    <input type="checkbox" id="Football" name="act[]" value="Football">
                                    <label for="Football">FootBall</label><br>
                                    <input type="checkbox" id="Basketball" name="act[]" value="Basketball">
                                    <label for="Basketball">BasketBall</label><br>
                                    <input type="checkbox" id="Nattation" name="act[]" value="Nattation">
                                    <label for="Nattation">Nattation</label><br>
                                    <input type="checkbox" id="Karate" name="act[]" value="Karate">
                                    <label for="Karate">Karate</label><br>
                                  </div>
                        </div>
              
                        <div class="box-footer">
                          <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                        </form>

PHP:(It doesnt insert values into the database)

    $checkBox = implode(',', $_POST['act']);

if(isset($_POST['submit']))
{       
    $query="INSERT INTO blooddonor (act) VALUES ('" . $checkBox . "')";     

    mysql_query($query) or die (mysql_error() );

    echo "Complete";

}

if(isset($_POST['name'])){
$name = $_POST["name"];    
$gender = $_POST["gender"];
$dob = $_POST["dob"];
$weight = $_POST["weight"];
$contact = $_POST["contact"];
$bloodtype = $_POST["bloodtype"];
$adress = $_POST["adress"];
include 'conn.php';

//code after connection is successfull
$qry = "insert into blooddonor(name,gender,dob,weight,contact,bloodtype,adress) values ('$name','$gender','$dob','$weight','$contact','$bloodtype','$adress')";
$result = mysqli_query($conn,$qry); //query executes

if(!$result){
    echo"ERROR";
}else {
    echo" <div style='text-align: center'><h1>ADDED SUCCESSFULLY</h1>";
    echo" <a href='index.php' div style='text-align: center'><h3>Go Back</h3>";

}

}else{
    echo"<h3>YOU ARE NOT AUTHORIZED TO REDIRECT THIS PAGE. GO BACK to <a href='index.php'> DASHBOARD </a></h3>";
}

DataBase:


CREATE TABLE IF NOT EXISTS `blooddonor` (
`id` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `gender` varchar(20) NOT NULL,
  `dob` date NOT NULL,
  `weight` int(5) NOT NULL,
  `contact` int(10) NOT NULL,
  `bloodtype` varchar(3) NOT NULL,
  `adress` varchar(50) NOT NULL,
  `act` varchar(50) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;



JavaFX .addAll() error with my own class?

        @Override
    public void start(Stage primaryStage) throws Exception {
        primaryStage.setTitle("Java Project");
        Scene scene;

        //File chooser
        FileChooser fileChooser = new FileChooser();

        Button button = new Button("Select Network File");
        button.setOnAction(e -> {
            String selectedFile = fileChooser.showOpenDialog(primaryStage).toString();
            Path file = Paths.get(selectedFile);
            System.out.println(file);
        });
        
        
        //Checkboxes
        Checkbox intBox = new Checkbox("Add interaction:");
        Checkbox degBox = new Checkbox("Get degree of node:");
        
        
        //Layout
        VBox layout = new VBox(10);
        layout.getChildren().addAll(button, intBox, degBox);
        layout.setAlignment(Pos.CENTER);

        primaryStage.setScene(scene);
        primaryStage.show();    
    }
}

on the .addAll() line, I'm getting error: The method addAll(int, Collection<? extends Node>) in the type List<Node> is not applicable for the arguments (Button, Checkbox, Checkbox

But I'm not extending Node anywhere? the Main class extends Application.

This is the Node class:

package application;

public class Node {

    public String name;
    
    public Node() {
        this.name = "";
    }

    public Node(String n) {
        this.name = n;
    }
    
    public String printName() {
        return name;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Node other = (Node) obj;
        if (name == null) {
            if (other.name != null)
                return false;
        } else if (!name.equals(other.name))
            return false;
        return true;
    }
    
}



Tkinter - Require checkboxes to be marked in order

I am trying to make a GUI with tkinter that is a checklist for operating a system. Each step has to be done in order before moving on to the next step. How to I set up the checkboxes such that each checkbox has to be marked before I can mark the next checkbox in the list? For example, I have to mark the first checkbox before I can mark the second.




asp.net c# gridview - individual row checkboxes for duplicates but final checkbox when satisfied

I am trying to write a meter tick and billing program in C# ASP.NET Webforms for a photocopier company. Some photocopiers have a B&W has as a Color meter. My Sql query presents 2 rows for the same photocopier so I may edit the monthly B&W and Color reads individually as they are billed at different rates. I wish to have one Invoice/Bill that shows both meter reads along with the final bill. Thus, until both meter reads have been entered it should not post. Once both the checkbox rows have been satisfied I require a third checkbox that checks them and then shows checked so they can be posted.