如何检查一个值(在我的复选框中)是否为真?在JavaScript循环中(在论坛上找不到)

问题描述 投票:-3回答:1

我想循环知道复选框的其中一个答案是否为“true”

我的代码Html:

<ion-list>  
  <ion-item *ngFor="let modalite of current.modalites ; let i=index">
    <ion-label>{{modalite}} {{i}}</ion-label>
    <ion-checkbox color="PFG" 
     [(ngModel)]="current.response[current.valModalites[i]]" checked="false">
    </ion-checkbox>
   </ion-item>
  </ion-list>

我的代码JS:

case "question_fermee_checkbox":
   console.log("checkbox");
   console.log(this.current.response,this.current.numero_question )
   while(verif < this.current.response.length){
      verif++
   } 
   retour= true;
  break;

谢谢您的帮助!

javascript angular ionic-framework
1个回答
0
投票

也许这样,未经测试,因为我没有你的设置。我刚刚填写了遗漏的内容。

case "question_fermee_checkbox":
   console.log("checkbox");
   console.log(this.current.response,this.current.numero_question )
   retour = false;
   for(var verif = 0; verif < this.current.response.length; ++verif){
      var checkbox = this.current.response[verif];
      if(checkbox.checked) {
          retour= true;
          break;
      }
   } 

  break;
© www.soinside.com 2019 - 2024. All rights reserved.