mardi 4 juin 2019

Still able to select disabled checkbox in Mat table

I have Mat table with a checkbox column. I am setting certain checkboxes to disabled based on certain conditions. However the user is still able to select the checkbox if the click on the row. How do I prevent the checkbox from being selected when disabled: Here is a stackblitz example I forked from the material design site: https://stackblitz.com/edit/angular-erpaus?file=app%2Ftable-selection-example.html. you can't click the check box but if you click outside of it the checkbox gets selected: enter image description here

<mat-checkbox (click)=      "$event.stopPropagation()"
                              (change)="$event ? selection.toggle(row) :null"
                              [checked]="selection.isSelected(row)" 
                              [disabled]="myCondition"
                               color="primary">
                </mat-checkbox>




Only One Checkbox to be Checked in combination with isotope not working in Safari

Isotope filtering on my website is not working correctly in Safari. Here is the problem: I have two checkboxes, when clicking the first one it filters the items just well. When I click the second checkbox the first is unchecked but the filtering does not work correctly. Thats only in Safari, in Firefox and Chrome it's working fine. Here's the code:

    <script type="text/javascript">
    //<!--


    $(window).load(function(){
var $container = $('#isocontainer');
// initialize
$container.isotope({
    itemSelector: '.item'
});
    });

    $(window).resize( function() {
var $container = $('#isocontainer');
// initialize
$container.isotope({
    itemSelector: '.item'
});
    });


    $(function(){

    var $container = $('#isocontainer'),
    $checkboxes = $('#filters input');

    $container.isotope({
    itemSelector: '.item',
    animationEngine: 'jquery'
    });

    $checkboxes.change(function(){
    var filters = [];
    // get checked checkboxes values
    $checkboxes.filter(':checked').each(function(){
    filters.push( this.value );
    });

    filters = filters.join(', ');
    $container.isotope({ filter: filters });
    });

    var $items = $container.children();

    $('input:checkbox').click(function() {
    $('input:checkbox').not(this).prop('checked', false);
    });

    });//-->

    </script>

Anyone have any ideas? And just to let you know: I have only very, very poor knowledge in javascript ...




Check another checkbox automatically inside loop

I am trying to do one new thing i.e. when i check one checkbox another checkbox will be checked automatically. I have two checkbox in each row i.e. it is in loop.

Here is my full code :

<?php 
include("config.php");

$sql="SELECT * FROM inventory_details where status ='0' AND role='0' ORDER BY position ASC, role ASC, visiter DESC limit 0,100";    
$query=mysqli_query($conn, $sql);

?>
<form method="post" action="" id="msform">  
  <div class="container">
      <div class="row invent_det cate_head">
        <div class="col-md-1 "><strong>Select </strong></div>
        <div class="col-md-1 "><strong>Select </strong></div>
      </div>

      <?php
        $i=0;
        $today_date=date("Y-m-d H:i:s", time()); 
        while($row=mysqli_fetch_assoc($query)){
        $id = $row['id'];
        $catagory_name = $row['catagory_name'];
        $PrimaryMobile_no = $row['PrimaryMobile_no'];
      ?>

      <div class="row" style="background-color: <?php echo $inventorybackground; ?> !important; color: <?php echo $inventorycolor; ?>; padding-top: 10px;">

        <div class="col-md-1 inventory-data">
          <input type="checkbox" id="checkItem" name="firm_name[]" value="<?php echo $firm_name;?>-<?php echo $PrimaryMobile_no;?>">
        </div>

        <div class="col-md-1 inventory-data">
          <input type="checkbox" id="checkItem" name="check[]" value="<?php echo $row["id"]; ?>">
        </div>
      </div>
<?php
$i++;
}
?>

  </div>
</form>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script>
<script  src="js/script.js"></script>

I have already tried some examples but failed to do so. I have implemented these https://jsfiddle.net/Bhawesh7731/4jsbLedn/

https://jsfiddle.net/Bhawesh7731/0ryts35u/

but when i check one checkbox, all the checkbox are checked automatically and i don't want that. I only want that, when i check the checkbox another checkbox of that row will be checked.




lundi 3 juin 2019

Store multiple values of checkboxer in database with LARAVEL

I'm new to laravel and I have doubts about how to take checkboxes and check if they have been selected, I also have the question of how to go through the arrangement. In my controller I want to enter 1 when it is true and 9 when it is false but I do not know how to set the values ​​because I do not even take them and enter the database.

Here part of my view

<div class="col-sm-3">  
        @php($titulo="")                   
        @foreach ($catalogocomponente as $cat)

        @if($cat->tipo!=$titulo&&$cat->num_tipo %2 == 1)

          <div class="title">
            <h3></h3>
            </div>
            @endif
             @if($cat->num_tipo %2 == 1)

    <div class="checkbox">
        <label>
            <input type="checkbox" id="check[]" name="check[]"  value="" onchange="javascript:showContent()">
            
        </label>
        <input name="" type="hidden" value="">
    </div>

    <!------------------ desplegable ---------------->  
    <div id="content[]" style="display: none;">
        <div class="col-md-12">
            <div class="form-group label-floating">
                <input type="text"  name="description" class="form-control"> 
            </div>
        </div>
    </div>  

    <!------------------ desplegable ---------------->  

        @endif
        @php($titulo=$cat->tipo)
    @endforeach
      </div>

Here my store controller

public function store(Request $request){
if ($request){
    $catalogocomponente=DB::table('catalogo_componente');
    $data=array();

  //  define('i',1);
    // i+1;         
    //$cameraVideo = $request->input('check'); //obtener el valor del arreglo de checks
    $cameraVideo=$request->input('check');
    //dd($cameraVideo);

        for($i=0; $i<5; $i++){
        dd($cameraVideo[$i]);
        //echo(i);
        //$data['id_componente']=$request->get('5');
        //$data['no_orden']=$request->get('no_orden');    
        //$data['disponibilidad']=$request->input('check');
        //$data['descripcion']=$request->get('descripcion');

       // $query_insert = DB::table('componente')->insert($data);
    /*   if( $cameraVideo){
        dd(true);
        var_dump($cameraVideo);

       }
    else{
    dd('no marcadoss');
    }*/ 

    // $i++;
        }


    return Redirect::to('hojatrabajo');
}

here part of my view enter image description here Other problem its amm 1 checkbox its equal to insert in database, please i need your help, thanks for reading me 😀




How to toggle on/off a geojson layer on a google maps html page

I'm confused about show and hide some geojson layer on a google map API V3 I want to set layer status by checkbox, i'dont know how to do this,

Now i'm able to set on more than 1 layer by the code below:

var geojesonlayer1 = new google.maps.Data();
var geojesonlayer2 = new google.maps.Data();
geojesonlayer1.loadGeoJson('mygeojson path');
geojesonlayer2.loadGeoJson('mygeojson path');
//layer style
geojesonlayer1.setStyle({
  strokeColor: 'yellow',
  strokeWeight: 5
});
geojesonlayer2.setStyle({
  strokeColor: 'blue',
  strokeWeight: 1
 });
//add layer to map
geojesonlayer1.setMap(map);
geojesonlayer2.setMap(map);
//remove layer from map
geojesonlayer1.setMap(null);
geojesonlayer2.setMap(null);




Auto fill the MultiCheckbox on back-end

I am creating an application on zend2 and I would like to get help. /* getMessages() returns array('info'=>'INFO','alert'=> 'ALERT','more','MORE'); */ $msg = array(); // my array foreach ($this->getMessages() as $key => $value) {

      //print_r($key);die();
      if(in_array($key,$user_values))
        $msg[$key][1] = 'user';
      if(in_array($key,$admin_values))
        $msg[$key][2] = 'admin';
      if(!in_array($key,$user_values) && !in_array($key,$admin_values))
        $msg[$key][] = 'skip';

        $form->get(trim($key))->setValueOptions(array($msg));
        // OR
        $form->get(trim($key))->setValue(array($msg));

        // Clear the array
        $msg = array();
    }
   /* Wanna into form :
      <input type="checkbox" name="alert[]" value="skip' />
      <input type="checkbox" name="alert[]" value="user' />
      <input type="checkbox" name="alert[]" value="admin' /> 
   */




best practice puppeteer waitForSelector or setTimeout

I try to find the best way to "wait until the complete website is loaded". And this seems to be a tricky thing. I was googleing alot and saw that there are 2 ways: waitForSelector and SetTimout.

My problem is, even if I wait for the Selector #CheckSelectAll to check this Checkbox it seems it's always too early. So I had to add a delay of 2 seconds. And this looks very unprofessional for me. I want to use the best practice for this.

This should be an issue everybody always needs when using puppeteer with different pages and forms.

Is it possible that this waitForSelector doesn't work when the selector is inside an iFrame?

Thanks for any advice and help!

  function delay(time) {
    return new Promise(function(resolve) { 
        setTimeout(resolve, time)
    });

  await page.waitForSelector('#CheckSelectAll');
  await delay(2000);
  await page.click('#CheckSelectAll');