Skip to main content
Inspiring
February 27, 2023
Answered

Create Dynamic CheckBoxes using String array and get values of each when button is clicked

  • February 27, 2023
  • 2 replies
  • 384 views

Hi there,
Need some help with this.
1.I have a string array and i want that many checkboxes to be created dynamically.

2.When i click button, i need to get values of created checkboxes (true or false).

var extenPanel = new Window("palette", "FontFixer", undefined, {
    borderless: false,
    resizeable: true
});

//Needed help here
//Array to use for dynamic checkboxes creation
var cbNames = ["Font01", "Font02","Font03"];

for(var i=0;i<cbNames.length;i++){
        eval('var '+ myvarName);
        extenPanel.cbNames[i]= extenPanel.add("checkbox",undefined,"myvarName");
        
}
///
extenPanel.btnContinue=extenPanel.add("Button",undefined,"OK");

extenPanel.onResizing = extenPanel.onResize = function() {
    this.layout.resize();
};

extenPanel.show()

extenPanel.btnContinue.onClick=function(){
    var myCheckedAry=[];
//Needed Help here
    for(var i=0;i<cbNames.length;i++){
       
         if(extenPanel.cbNames[i].value){
             myCheckedAry.push(cbNames[i]);
        }
        
    }

}

 

This topic has been closed for replies.
Correct answer manjunath MK

Now I understand why people not answering.. Coz its silly question.. Ha ha.. 

I figured it out that I have to just push check boxes into an array while its created and then use that array for check box values. Funny.

2 replies

manjunath MKAuthorCorrect answer
Inspiring
March 1, 2023

Now I understand why people not answering.. Coz its silly question.. Ha ha.. 

I figured it out that I have to just push check boxes into an array while its created and then use that array for check box values. Funny.

Inspiring
March 1, 2023

Is it difficult to achieve? or is it not possible? Can someone help here please?