Retrieving NEW values from the form

function create_file(){
dhx.ui({
view:“window”,
id:“create_file_window”,
width:350,
head:{ view:“toolbar”,
type:“MainBar”,
data:[{type:“label”, label:“Create new file”, align:“center”}]
},
body:{
rows:[
{ view:“form”,
id:“form1”,
data:[
{type:“text”,id:“filename”,label:“Name”,labelWidth:150,inputWidth:150,width:300,value:“name”},
{type:“text”,id:“noc”,label:“No of columns”,labelWidth:150,inputWidth:150,width:300}
]
},
{view:“toolbar”,type:“SubBar”,
data:[
{type:“button”,label:“Ok”,align:“center”,click:“add_col_details($$(‘form1’).item(‘filename’).value)”},
{type:“button”,label:“Cancel”,align:“center”,click:“close_create_file_window”}
]
}
]
},
position:“center”
})
}

Now what happens is that the old value of filename gets passed to the function even when I change it in the form after running. I kept the value attribute as blank. And then gave the value after running, that time blank value is passed. I wanted to know how to pass the new value entered by the user.
Please help

The correct approach is:

{type:“button”,label:“Ok”,align:“center”,click:“add_col_details”},

function add_col_details(){
var value = $$(‘form1’).item(‘filename’).value;
/other code here/
}

Still the blank values are getting retrieved. In that ‘value’ variable blank value is getting stored.
User entered values are not getting retrieved.

Sorry, that method can not be applied to form. Try the following approach:

var value = $$(‘form1’).getValues().filename;

getValues() method returns all values.

Or else If I write value=‘abc’ attribute then the same value gets retrieved even if user modifies that value in the textbox in the form.
Please help.
Thank you.

Sorry for the above reply. Didn’t realise you had replied.
Thanks a lot. getValues() method worked. Actually I had tried that method but used getValues(id) instead of getValues().id
Thanks a lot.

Now suppose the situation is like I have ‘id’ stored in a variable.
var userid=“id1”;

And then if I give
$$(‘form2’).getValues().userid;
it doesn’t work.

The problem is that, I have used the above statement in a for loop. And hence the id is dependent on the looping variable i.
So I used
var userid=“id”+i;
$$(‘form2’).getValues().userid;

That doesn’t work. I cannot put
$$(‘form2’).getValues().“id”+i;
It again doesn’t work.

How to proceed ?
Please help.

getValues returns hash of values. Therefore, you may use the following:

var userid=“id1”;

var values = $$(‘form2’).getValues();
var user = values[userid];

Thanks again.