hi all, in a replicant, i have 3 fields that display based on the selection of a radio button. when the form first loads, it checks to see the selection is no, and if so, then hides the 3 fields. when a replicant is added, it hides the 3 fields. Then when the user makes a change with the radio button, it hides the 3 fields if the user changes to no.
The onchange for the radio button works for first blank entry but it will not change the visibility after a replicant has been added. any idea what might be happening?
[
]
IWEventRegistry.addFormHandler("onFormInit", init);
function init(){
setup();
IWEventRegistry.addItemHandler("/years/year/months/month/nrs/nr", "OnReplicantAdded", onAdd);
IWEventRegistry.addItemHandler("/years/year/months/month/nrs/nr/fp", "onItemChange", setVisi);
}
function setup() {
var controlledItem = IWDatacapture.getItem("/years/year/months/month/nrs/nr");
var children = controlledItem.getChildren();
for (var i=0; i < children.length; i++){
var replicantInstance = children;
var fpItem = replicantInstance.getChildByName("fp");
var headlineItem = replicantInstance.getChildByName("headline");
if (fpItem.getValue() == "1") {
headlineItem.setVisible(false);
}
}
}
function onAdd(item) {
var path = item.getName();
var headlinePath = path + "/headline";
IWDatacapture.getItem(headlinePath).setVisible(false);
}
function setVisi(item) {
var path = item.getName();
var headlinepath = path + "/../headline";
var captionpath = path + "/../caption";
var fpItem = item.getValue();
if (item.getValue() == "0") {
alert(path);
toggleItem(headlinepath, "show");
toggleItem(captionpath, "show");
}
else {
toggleItem(headlinepath, "hide");
toggleItem(captionpath, "hide");
}
}
function toggleItem(instance, view) {
if (view == "show") {
alert("works");
IWDatacapture.getItem(instance).setVisible(true);
}
else {
IWDatacapture.getItem(instance).setVisible(false);
}
}
[