Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
setValue() usinf FORM API
TeamsiteUser
Hello,
I have a radio button in datacapture.cfg for which i need to set the value and its visiblility using form api.
datacapture.cfg code for radio button is attached :
The requirement is that depending on value of the select box value(classification), we have to set the value and its visiblilty of this radio button(which is under a container).
function init() {
IWEventRegistry.addItemHandler("/classification","onItemChange", changeTypes) ;
changeTypes();
}
function changeTypes(){
var item = IWDatacapture.getItem("/classification");
var typeValue = item.getValue();
if(typeValue != null)
{
var selectedType = item.getOptions()[typeValue].text;
var hid = IWDatacapture.getItem('/Required Fields/hidden');
if (selectedType == "Overview") {
hid.setVisible(true);
hid.setRequired(true);
}
else if (selectedType == "Homepage") {
hid.setValue(1);
hid.setVisible(false);
}
IWDatacapture.redraw();
}
}
This code works fine when we call this function on Item change of that select box. But the same code does not work on the initial load of DCR. After putting lot of alerts, i found out that the error is on statement
hid.setValue(1);. It does not execute any line after this line and it just gets out of the method during initial load but it works fine absolutely on item change of select box..
This code was working on TS 5.5 but has stopped working as we have upgraded to TS 6.5 SP2
Please help me out in this issue.
Find more posts tagged with
Comments
Adam Stoller
Please show the line of FormAPI code that
calls
the
init
function.
Dwayne
In all probability (as Ghoti is implying) you're calling your init() function before the form has been fully loaded, so "hid" is still null, and you get your error.
Rather than running init() in-line in your code, substitute your init() call with this:
IWEventRegistry.addFormHandler("onFormInit", init);
See if that makes a difference