»User: »Password:   Remember Me? 
ScriptUI Forums / ScriptUI / ScriptUI Q&A / Radio button validate
Posted:  01 Jun 2009 13:41
In this code i have problem with validate two radio button rb1 and rb2. could anyone tell me how to below

i attached





var rb1;
var indesign_path="";
var indesign_path1="";
var indesign_path2="";
myDlg = new Window("dialog", "Sample");
myDlg.orientation = "column" ;
myDlg.size = [465,180];

//myDlg.alignment="justify";
var s1=myDlg.add('group')
var s2=myDlg.add('group')
var s3=myDlg.add('group')
//var s1=myDlg.add('group')
s1.lable = s1.add("statictext", undefined, "Choose InDesign Source Folder");
s1.btn1 = s1.add("button", undefined, "Browse");
s1.txtBx1 = s1.add("edittext{justify:'left'}", undefined, "");
s1.txtBx1.characters=15;
//myDlg.btn2 = myDlg.add("button", undefined, "Dest Selection");
//myDlg.txtBx1 = myDlg.add("edittext{justify:'left'}", undefined, );

s2.lable = s2.add("statictext", undefined, "Choose Indesign Desti Folder ");
s2.btn2 = s2.add("button", undefined, "Browse");
s2.txtBx2 = s2.add("edittext{justify:'left'}", undefined, "sample alert");
s2.txtBx2.characters=15;

s3.lable = s3.add("statictext", undefined, "Choose Either One");
s3.btn3 = s3.add("button", undefined, "CSV file select");
rb1 = s3.add ('radiobutton', undefined, 'SinglePage PS');
    rb1.value = true;
    var rb2 = s3.add ('radiobutton', undefined, 'SelectedPage PS ');


s1.btn1.onClick = function()
{
indesign_path=Folder.selectDialog("Choose a Indesign folder");
if(indesign_path==null)
{exit();}
indesign_path=indesign_path.toString();
s1.txtBx1.text = indesign_path;
}
if(s1.show())
{
alert(indesign_path)

}
//exit();
s2.btn2.onClick = function(){
indesign_path1=Folder.selectDialog("Choose a Indesign folder");
if(indesign_path1==null)
{exit();}
indesign_path1=indesign_path1.toString();
s2.txtBx2.text = indesign_path1;
}
if(s2.show())
{
alert(indesign_path1)   

}

/*s3.btn3.onClick = function(){
//indesign_path=Folder.selectDialog("*.csv").getElements();

indesign_path2=File.openDialog("Select CSV Files", "File Types: *.csv, *.PSD");
/*if(indesign_path==null)
{exit();}
indesign_path=indesign_path.toString();
//myDlg.txtBx2.text = indesign_path;
}*/

s3.btn3.onClick = function()
{
    if(myDlg.show()==true)
    {
       if (rb2.checkedState==true&&(rb1.checkedState!=true))
       {
     indesign_path2=File.openDialog("Select CSV Files", "File Types: *.csv, *.PSD");
    }}
}

     

if(myDlg.show())
{
    alert(indesign_path)   
    alert(indesign_path1)   
alert(indesign_path2)   
}

//exit();
Posted:  01 Jun 2009 14:26
Here is th fixed code.

Two things
1) value property gets you the checkedState of radiobutton
2) show() is a function not a property and can't be used to check visibility. really a modal dialog doesn't need to check visibility. If you do need to check for whatever reason use visible property

Code:

var rb1;
var indesign_path="";
var indesign_path1="";
var indesign_path2="";
myDlg = new Window("dialog", "Sample");
myDlg.orientation = "column" ;
myDlg.size = [465,180];

//myDlg.alignment="justify";
var s1=myDlg.add('group')
var s2=myDlg.add('group')
var s3=myDlg.add('group')
//var s1=myDlg.add('group')
s1.lable = s1.add("statictext", undefined, "Choose InDesign Source Folder");
s1.btn1 = s1.add("button", undefined, "Browse");
s1.txtBx1 = s1.add("edittext{justify:'left'}", undefined, "");
s1.txtBx1.characters=15;
//myDlg.btn2 = myDlg.add("button", undefined, "Dest Selection");
//myDlg.txtBx1 = myDlg.add("edittext{justify:'left'}", undefined, );

s2.lable = s2.add("statictext", undefined, "Choose Indesign Desti Folder ");
s2.btn2 = s2.add("button", undefined, "Browse");
s2.txtBx2 = s2.add("edittext{justify:'left'}", undefined, "sample alert");
s2.txtBx2.characters=15;

s3.lable = s3.add("statictext", undefined, "Choose Either One");
s3.btn3 = s3.add("button", undefined, "CSV file select");
rb1 = s3.add ('radiobutton', undefined, 'SinglePage PS');
    rb1.value = true;
    var rb2 = s3.add ('radiobutton', undefined, 'SelectedPage PS ');


s1.btn1.onClick = function()
{
indesign_path=Folder.selectDialog("Choose a Indesign folder");
if(indesign_path==null)
{exit();}
indesign_path=indesign_path.toString();
s1.txtBx1.text = indesign_path;
}
if(s1.show())
{
alert(indesign_path)

}
//exit();
s2.btn2.onClick = function(){
indesign_path1=Folder.selectDialog("Choose a Indesign folder");
if(indesign_path1==null)
{exit();}
indesign_path1=indesign_path1.toString();
s2.txtBx2.text = indesign_path1;
}
if(s2.show())
{
alert(indesign_path1)   

}

/*s3.btn3.onClick = function(){
//indesign_path=Folder.selectDialog("*.csv").getElements();

indesign_path2=File.openDialog("Select CSV Files", "File Types: *.csv, *.PSD");
/*if(indesign_path==null)
{exit();}
indesign_path=indesign_path.toString();
//myDlg.txtBx2.text = indesign_path;
}*/

s3.btn3.onClick = function()
{
    if(myDlg.visible==true)
    {
       if (rb2.value==true&&(rb1.value!=true))
       {
     indesign_path2=File.openDialog("Select CSV Files", "File Types: *.csv, *.PSD");
    }}
}

     

if(myDlg.show())
{
    alert(indesign_path)   
    alert(indesign_path1)   
alert(indesign_path2)   
}

//exit();