简体   繁体   English

使用此代码javascript检查其他条件

[英]Check for one more condition with this code javascript

This is my code 这是我的代码

//Remove disabled class from the next step button
  var element = document.getElementById('stepbirth');
  element.classList.toggle("disabled", parseJson.some(function (resp) {
    return !resp.code;
  }));

Which is working fine, it check the response from the php script on each element and toggle the disabled class from the button. 一切正常,它检查每个元素上php脚本的响应,并从按钮切换禁用的类。

My question is this, How can i check one or more condition with this code.. Like i also have input type radio in the same form, how can i combine this together to check while input radio is checked on each class and response code is 1 then remove disabled class else do not remove disabled class. 我的问题是,我怎样才能用此代码检查一个或多个条件。就像我也有输入形式的单选形式一样,当在每个班级检查输入单选和响应代码时,如何将它们组合在一起检查1然后删除禁用的类,否则不要删除禁用的类。

I hope you understand guys my question. 我希望你能理解我的问题。

Thanks in advance. 提前致谢。

One way to do this would be to return true or false by checking if all the conditions are met. 一种方法是通过检查是否满足所有条件来返回true或false。 Something like this: 像这样:

//Remove disabled class from the next step button
var element = document.getElementById('stepbirth');
element.classList.toggle("disabled", parseJson.some(function (resp) {
return (resp.firstcondition && resp.secondcondition && resp.thirdcondition);
}));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM