如何在选择添加按钮时禁用先前选择的字段,并在按下删除按钮时删除禁用。这个流程应该一直持续到最后。这是链接 注意:禁用功能仅适用于所选选项,不适用于选择。在下一行中,该选项应被禁用,并在删除该选项时应启用
单击添加按钮(禁用所选字段选项)和删除按钮(启用所选选项按钮)时类似循环
请参阅下面的代码,您可以对其进行跟踪。
var staticPrefills = [{
"questionId": "5e578b7d30bb2fd60c1f9855",
"note": "Mobile Number",
"prefillValue": null
},
{
"questionId": "5e578b8930bb2fd60c1f985c",
"note": "Email",
"prefillValue": null
},
{
"questionId": "5e578b9330bb2fd60c1f985f",
"note": "Name",
"prefillValue": null
},
{
"questionId": "5e578ba930bb2fd60c1f9862",
"note": "Agent ID",
"prefillValue": null
},
]
var staffPrefillArray = []
function generateJson(){
var divchildlength = $("#buildyourform").children().length;
staffPrefillArray = [];
for(var i = 0; i < divchildlength; i++ ){
var selectValue= $(`#buildyourform div:nth-child(${i + 1}) select`).val();
var textValue= $(`#buildyourform div:nth-child(${i + 1}) input`).val();
var selectAttrValue = $(`#buildyourform div:nth-child(${i + 1}) select option:selected`).attr('questionId');
// console.log(selectValue);
// console.log(textValue);
// console.log(selectAttrValue);
var generateJsonvalue = {
"questionId": selectAttrValue,
"note": selectValue,
"prefillValue": textValue
}
staffPrefillArray.push(generateJsonvalue);
}
console.log(staffPrefillArray);
}
for(var i=0; i<staticPrefills.length; i++){
$('#static-select-prefills').append(`<option questionId="${staticPrefills[i].questionId}" value="${staticPrefills[i].note}">
${staticPrefills[i].note}
</option>`);
}
哔哔one
白板的微信
Qyouu
相关分类