loading external JSON elements

Hello!
I load my form from a son file …
“myForm.loadStruct(”./analytics1/formEric.json", function(){});"

How do I do this at the same time?
“myForm.setItemValue(“x_y_z”, 0);”

I started with the form IN the webpage, in a json-like-text. When the form text was PART OF the doOnLoad command, everything worked perfectly. NOW, I extracted the form to an external son file (see above) and all my form modifying lines (like multiple setItemValue & things like… “document.getElementsByName(“form_element”)[0].value = <?php echo ($loggedIn)?$_SESSION["userID"]:0;?>;”)… all of these form-modifying lines don’t work AND show errors in the debug console.

Do i have the lines in the wrong order??
How do I include form-modifying code into this page? how/where? do i put all the form-modifying-code in an external js file or something & include the js file into the head?

Here’s a short-hand of the pages’ code…
function doOnLoad() {
var myForm = new dhtmlXForm(“vp”);
var dp = new dataProcessor("./analytics1/timewarp.php");
var dhxCalendar = myForm.getCalendar(“myCalendar”);
//dp.init(myForm);//link form to dataprocessor
myForm.loadStruct("./analytics1/formEric.json", function(){});
//set some default values.
myForm.setItemValue(“time_analyst_confidence”, 0);
myForm.setItemValue(“time_classification”, 2);
myForm.setItemValue(“time_agent_ID”, 0);
myForm.setItemValue(“time_work_location”, 0);
etc…
Close head & close doOnLoad…

Entry Page

etc…

Hi

myForm.loadStruct("./analytics1/formEric.json", function(){ // this is callback function, it called after json loaded and parsed by form, // exatly here form items become existing, i.e. you can call: myForm.setItemValue(..); });

the same with calendar:

var dhxCalendar = myForm.getCalendar("myCalendar");

if {type:calendar,name:myCalendar} declared in formEric.json, you also need to move myForm.getCalendar to callback above.

Hello!
Thanks for the reply!
Based on your answer, the myForm.setItemValue() are correct in my code… but no itemValues get set.

When I had the entire form written as-part-of the code, the values would set.
When I took the form out of the code and put it in a separate json file, the itemValues wouldn’t update.

Do I have to set the NAME of the item or the ID of the item? Currently, I have the NAME of the item matching the seItemValue command. Maybe if I ad an “id” to the item, the setItemValue will work.
I don’t understand why the setItemValue doesn’t set after the Form has been extracted & set in a jSON file.

Thanks!
-Eric-

Hello
To help you with this question we need completed demo.
docs.dhtmlx.com/auxiliary_docs__ … pport.html
Please, provide it on support@dhtmlx.com with link to this topic