从Javascript动态创建的组中隐藏一个单选按钮

从Javascript动态创建的组中隐藏一个单选按钮,javascript,html,Javascript,Html,我早些时候问过这个问题,但帖子不连贯,也不清楚。我们又来了 我们使用Javascript动态生成一个页面。这部分代码用于创建一组单选按钮: Dead, Trans, Hospital, Removed 现在我需要隐藏单选按钮“删除”时,它的取消选中,只显示其他3。Javascript代码: //Create the main RadioDiv and append radio options var radioQuestion = document.createElement("div");

我早些时候问过这个问题,但帖子不连贯,也不清楚。我们又来了

我们使用Javascript动态生成一个页面。这部分代码用于创建一组单选按钮:

Dead, Trans, Hospital, Removed
现在我需要隐藏单选按钮“删除”时,它的取消选中,只显示其他3。Javascript代码:

//Create the main RadioDiv and append radio options
var radioQuestion = document.createElement("div");
radioQuestion.setAttribute("id", name + "RadioDiv");
fsRadio.appendChild(radioQuestion);
//For each radio button option do the following
for (var d = 0; d < optionList.length; d++) {
    var name = optionList[d].name;
    var value = optionList[d].value;
    //This creates the input field for each option
    var radioItem = document.createElement("input");
    radioItem.setAttribute('type', "radio");
    radioItem.setAttribute('name', flId);
    radioItem.setAttribute('id', flId + "_" + name);
    radioItem.setAttribute('value', value);

    if (flId != null && flId === 'reasonCode' 
        && name != null && name === 'Removed') {
         console.log("radio::"+flId + "_" + name);
         //Code to hide the button here?
    }

    if (status === null || status === "" ||
        status === false ||
        typeof status === 'undefined') {
        radioItem.setAttribute('class',
            "inactive-field");
        radioItem.setAttribute('disabled', "disabled");
    } else if (status === true) {
        radioItem
            .setAttribute('class', "active-field");
    }

    //This creates the label
    var radioLabel = document.createElement("label");
    radioLabel.setAttribute('for', flId + "_" + name);
    radioLabel.textContent = name;
    var objDiv = document.createElement("div");
    objDiv.setAttribute('class', "q-radio");
    objDiv.appendChild(radioItem);
    objDiv.appendChild(radioLabel);
    //Append all radio buttons to the main RadioDiv - radioQuestion
    radioQuestion.appendChild(objDiv);
    if (radioItem.value == flValue && flValue != null && flValue != undefined && flValue != "") {
        radioItem.setAttribute('checked', "checked");
    } //end of if statement

} //end of For loop
//创建主RadioDiv和附加radio选项
var radioQuestion=document.createElement(“div”);
radioQuestion.setAttribute(“id”,name+“RadioDiv”);
fsRadio.appendChild(radioQuestion);
//对于每个单选按钮选项,请执行以下操作
对于(var d=0;d
希望这次的帖子是相关的。非常感谢你的帮助。另外,如果需要更多的细节,请告诉我


谢谢

选项列表
中删除
是否是一个选项?如果它从未被创造过,就不需要隐藏…@jessh,这真是个好主意。多谢。我会调查的