单击复选框检查值

时间:2018-09-13 16:10:15

标签: javascript angularjs zend-framework

有问题的问题是,如果atendimento号码(atendimento.value)与先前输入的号码不同,则不允许我单击复选框。 当我第一次单击1复选框时,我将存储此值和对数组的推送。

如果我单击另一个复选框,并且atendimento.value不同,它将显示带有吐司的错误消息。

我想知道我在代码中遗忘的内容。

ng.checkAtendimento = function(id) {

    var atendimento = document.getElementById('atendimento-' + id);
    var checkOs = document.getElementById('checkOs-' + id);
    var array = [];

    if(checkOs.checked){
        array.push(atendimento.value);
        console.log(array);
    }else{  
        var index = array.indexOf(atendimento.value);
        array.splice(index, 1); 
        console.log(array);
    }

    if(array[0] != atendimento.value){
        console.log(array[0]);
            toastr.error(
                        'error',
                        'service', {
                        closeButton: true,
                        progressBar: true,
                        timeOut: 7000
                });
        checkOs.checked = false;
    }
}

HTML / PHP

<input id="checkOs-<?php echo $entity->getId(); ?>" 
       ng-click="checkAtendimento('<?php echo $entity->getId(); ?>');" 
       type="checkbox" 
       class="array-ordemservico" 
       name="[]array-ordemservico" 
       value="<?php echo $entity->getId();?>" />

<input id="atendimento-<?php echo $entity->getId(); ?>" 
       class="array-atendimento" 
       style="display:none" type="checkbox" 
       value="<?php echo $entity->getAtendimento(); ?>" />

1 个答案:

答案 0 :(得分:0)

List<Meal> list1=[Meal(dis:'it is a chicken sandwichh',name: 'chekin filla',dat: '20th of september 2018',today:DateTime.now().subtract(Duration(days:2)),butcolor: Colors.grey),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla',dat:'21th of september 2018',today:DateTime.now().subtract(Duration(days:1)),butcolor: Colors.grey),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla',dat:'22th of september 2018',today:DateTime.now(),butcolor: Colors.grey),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla',dat:'23th of september 2018',today: DateTime.now().add(Duration(days:1)),butcolor: Colors.grey),
Meal(dis:'it is a chicken sandwichh',name: 'chekin filla',dat:'24th of september 2018',today: DateTime.now().add(Duration(days:2)),butcolor: Colors.grey)];

switchcolor(Color x ){
  setState(() {
if (x==Colors.yellow){
  x=Colors.grey;
}
else{
  x=Colors.yellow;
}
 });
}
child:IconButton(
              onPressed:(){ hi(element.today)?null:switchcolor(element.butcolor);},
              icon:Icon(Icons.star),color:element.butcolor,)),

}); }