Home
TeamSite
Form API
jkm
Hi, I wrote a simple formapi and in that I was putting some alert messages to debug it. It showed me messages intially but it stopped after tht. Is this some browser caching problem
Here is the code
function init()
{
IWEventRegistry.addFormHandler("onFormInit", init);
IWEventRegistry.addItemHandler("/about_index/top_index/about_index_list/radio_button", "onItemChange", selectI
tem);
}
function selectItem() {
var Value = IWDatacapture.getItem("/about_index/top_index/about_index_list/radio_button");
var title = IWDatacapture.getItem("/about_index/top_index/about_index_list/title");
alert("function");
#var val=Value.getOptions()[Value.getValue()].text;
#alert("Value");
if ( Value.getOptions()[Value.getValue()].text == "Index") {
title.setVisible(false);
}
}
init();
solaris 8 + TS 6.5
anyidea why its happening or is this something wrong in this code ?
Find more posts tagged with
Comments
Nidhi_Agrawal
init function handler shud be outside of fun.and no need of init() calling ..
Just use this code.
function init()
{
IWEventRegistry.addItemHandler("/about_index/top_index/about_index_list/radio_button", "onItemChange", selectI
tem);
}
function selectItem() {
var Value = IWDatacapture.getItem("/about_index/top_index/about_index_list/radio_button");
var title = IWDatacapture.getItem("/about_index/top_index/about_index_list/title");
alert("function");
#var val=Value.getOptions()[Value.getValue()].text;
#alert("Value");
if ( Value.getOptions()[Value.getValue()].text == "Index") {
title.setVisible(false);
}
}
IWEventRegistry.addFormHandler("onFormInit", init);
Adam Stoller
There's still a problem with the code as posted.
Usually when the javascript fails to execute it is because there is a syntax error, in this case, it was because of two perl-esque comments in selectItem() which can be fixed as highlighted below:
function init()
{
IWEventRegistry.addItemHandler("/about_index/top_index/about_index_list/radio_button",
"onItemChange", selectItem);
}
function selectItem() {
var Value = IWDatacapture.getItem("/about_index/top_index/about_index_list/radio_button");
var title = IWDatacapture.getItem("/about_index/top_index/about_index_list/title");
alert("function");
//
#var val=Value.getOptions()[Value.getValue()].text;
//
#alert("Value");
if ( Value.getOptions()[Value.getValue()].text == "Index") {
title.setVisible(false);
}
}
IWEventRegistry.addFormHandler("onFormInit", init);
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jkm
Thanks for your reply but its still not working ... Is this replicant causing some issues . not able to see any alert message still
jkm
Thanks Adams for pointing correct. I am able to see the alert boxes etc but getting an error in java script which seems to be happening because of replicants. Am i using the right way to refer replicants as about_index_list is a container and it has replicants?
jkm
Is there any way to get the current item on which event has happened .. cant we refer that event using "this" object in FormAPI.. I want to hide the text box on change of radio button but I am not able to get the replicant number and I need to traverse all the elements to fix this . .. any other better way to do this
JonathonG
Just change your event handler function prototype to take an argument. The framework passes you the item that has changed, your function just needs to receive it.
Jonathon
Interwoven Developer
Allstate, Inc.
Adam Stoller
Maybe it's the holiday spirit, but to expand on JG's post I believe you want to do something like:
function selectItem(
radio_button_item
) {
//
var Value = IWDatacapture.getItem("/about_index/top_index/about_index_list/radio_button");
var title = IWDatacapture.getItem(
radio_button_item.getName().replace(/radio_button/, "title")
);
alert("function");
var radio_button_value = radio_button_item.getOptions()[radio_button_item.getValue()].text;
if (
radio_button_value
== "Index") {
title.setVisible(false);
}
}
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
jbonifaci
If it were the holiday spirit, shouldn't your post have been green and red, not blue and red?
~Jeff