IWDatacapture.getItem("/subsection_headlines["i"]/check_box")
IWDatacapture.getItem("/subsection_headlines[" + i + "]/check_box")
try {var item = IWDatacapture.getItem("/subsection_headlines["i"]/check_box");}catch (err) { alert ("An error occured: " + err + (err.description ? " - " + err.description : "");}
in your loop IWDatacapture.getItem("/subsection_headlines["i"]/check_box") I believe if should be: IWDatacapture.getItem("/subsection_headlines[" + i + "]/check_box") I am not sure javascript will know to concataine the strings if you don't put the + operator in there. And Javascript is very sensitive, when there is an error somewhere it will throw an exception. If there is no try - catch block to do something about the exception, the whole javascript bit will stop working right then and there!Little advice, when working with javascript, always surround your code with a try - catch block, even if the error message is sometimes cryptic at least it can help you find where the problem is.example: try {var item = IWDatacapture.getItem("/subsection_headlines["i"]/check_box");}catch (err) { alert ("An error occured: " + err + (err.description ? " - " + err.description : "");} This will display the error general message plus the description which can help narrow it down.Hope this helps!
function setCheckBox(){ alert ("This is begining of function."); var para = IWDatacapture.getItem("/centre/Main_News/Headlines/subsection_headlines").getChildren(); alert("getchildren ......"+para); for (var i=0; i<para.length; i++) { var paraItem = IWDatacapture.getItem("/subsection_headlines["i"]/check_box"); var paraText = paraItem.getValue(); if(paraText.checked == true) { alert("if condition......"+paraText); paraText.setValue = true; } if(!paraText.checked) { alert("else condition ......"+paraText); paras.setValue = false; } } return true;}
function setCheckBox(){ alert ("This is begining of function."); return true;}
Hi YannNow this is my code but not getting any alert. function setCheckBox(){ alert ("This is begining of function."); var para = IWDatacapture.getItem("/centre/Main_News/Headlines/subsection_headlines").getChildren(); alert("getchildren ......"+para); for (var i=0; i<para.length; i++) { var paraItem = IWDatacapture.getItem("/subsection_headlines["i"]/check_box"); var paraText = paraItem.getValue(); if(paraText.checked == true) { alert("if condition......"+paraText); paraText.setValue = true; } if(!paraText.checked) { alert("else condition ......"+paraText); paras.setValue = false; } } return true;} if i try: function setCheckBox(){ alert ("This is begining of function."); return true;} then only i get this alert message when i click on checkbox.Please suggest me.
Are you using multiple / multi-level containers?Can you please post your DCT code also?
yes i m using multiple containers.Please find attached code.
var paraItem = IWDatacapture.getItem("/subsection_headlines["i"]/check_box");
var paraItem = IWDatacapture.getItem("/subsection_headlines[" + i + "]/check_box");
var paraItem = para;
you still have a bit of a problem, the reason you don't get any alerts is because you still have the same syntax error var paraItem = IWDatacapture.getItem("/subsection_headlines["i"]/check_box"); should be something like var paraItem = IWDatacapture.getItem("/subsection_headlines[" + i + "]/check_box"); but even so, it won't work, your paraItem should be retrieved like so (I think): var paraItem = para; IWDatacapture.getItem() works with a name starting from the root node.Keep in mind each IWItem also have a getChildByName() function which can also be helpful.
para
function setCheckBox(){ alert ("This is begining of function."); var para = IWDatacapture.getItem("/centre/Main_News/Headlines[1]/subsection_headlines").getChildren(); alert ("child items...."+para); var para1 = para.length; for (var i=0; i<para1; i++) { alert ("length...."+para1); var paraItem = para/"check_box"; alert("cb item "+paraItem); var paraVal = paraItem.getOptions()[paraItem.getValue()].value; alert("label...."+cbval); if(paraVal.checked == true) { alert("if condition......"+paraVal); break; } if(!paraVal.checked) { alert("else condition ......"+paraVal); paraVal.setValue = false; } } return true;}
var para = IWDatacapture.getItem("/centre/Main_News/Headlines[1]/subsection_headlines").getChildren();
var para = IWDatacapture.getItem("/centre/Main_News/Headlines")[1].getItem("subsection_headlines").getChildren();
your code: var para = IWDatacapture.getItem("/centre/Main_News/Headlines[1]/subsection_headlines").getChildren(); try this: var para = IWDatacapture.getItem("/centre/Main_News/Headlines")[1].getItem("subsection_headlines").getChildren();
var paraVal = paraItem.getOptions()[paraItem.getValue()].value;
var paraVal = paraItem.getValue();
to retrieve the value of checkbox, but still not getting. As i have a single option in my checkbox item.getOptions() returns array of option, so is that the reason i m not getting value ? How i retrieve checkbox value ?
if (paraItem.getValue() != 0) { // checkbox is checked} else { // checkbox is uncheck}
Thanks for reply waikong but no success
... var paraItem = para/"check_box";...
... var paraItem = IWDatacapture.getItem(para.getName() + "/check_box");...
I have the similar setting on my DCT. Because the checkbox is either check or uncheck, in other work, true or false. So here is how I compare their value: if (paraItem.getValue() != 0) { // checkbox is checked} else { // checkbox is uncheck}
if(paraItem.getValue() != null) { alert ("i value "+i); for (k=0; k<=para1; k++ ) { var chItem = IWDatacapture.getItem(para.getName() + "/check_box"); chItem.setValue([1]); } } else { alert ("checkbox is check"); }
Thanks Adam, now getting alerts.i need to set checkbox value. trying to get i value its "0". if(paraItem.getValue() != null) { alert ("i value "+i); for (k=0; k<=para1; k++ ) { var chItem = IWDatacapture.getItem(para.getName() + "/check_box"); chItem.setValue([1]); } } else { alert ("checkbox is check"); } need a value for the uncheck box so that i can set that value for all the uncheck boxes. i am able to unselect underneath checkbox but upper one also get unselected.