Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
"OnClick" for IWEventRegistry
gururaj
I'm not able to call a handler as soon as field is clicked
code:
IWEventRegistry.addItemHandler("/Topic/Question and Answer/Answer", "onClick", QuestionHandler);
As soon as "Answer" is clicked Question has to be checked.
function QuestionCheck(Answer)
{
if(IWDatacapture.getItem(Answer.getName()+"/../Question").value == "");
{
alert("Add the Question first");
}
}
This code is also not working.I'm not able to get the Value of Question and then check if there is a question.The " if" loop is entered for all the conditions i.e if there is a question also.
datacapture.cfg code:
<container name="Topic" combination="and">
<description>Enter Question and Answer for this Topic</description>
<item name="Topic">
<label>Topic Name</label>
<text required="t" size="50" maxlength="100" />
</item>
<item name="Question and Answer">
<replicant max="10" default="1">
<item name="Question">
<label>Question</label>
<textarea required="t" wrap='physical' cols="50" rows="2"/>
</item>
<item name="Answer">
<label>Answer</label>
<textarea required="t" wrap='physical' cols="50" rows="2"/>
</item>
<item name="Image" rowcontinue="f">
<description>Please attach the image</description>
<label>Image</label>
<browser rowcontinue="t" maxlength="255" size="15" extns=".gif,.jpg" ceiling-dir="/images" initial-dir="/images"></browser>
</item>
<item name="Caption" rowcontinue="f">
<description>Enter the Caption</description>
<label>Caption</label>
<text required="f" maxlength="40" size="72" />
</item>
</replicant>
</item>
</container>
Please reply to me if u have any other solutions for it.
Find more posts tagged with
Comments
JonathonG
Hmm, it would seem that your best bet would be to start with the FormAPI documentation, located at:
http://YOURTSSERVER/iw/help/tst/formapi
If you look there, you'll notice that there is no "onClick" event. Perhaps an onItemChange event registered on the correct item could solve your problem? You could register an onItemChange on the Answer, and then check to see if there is a question. I know this wouldn't occur as soon as an onClick, but I think that's the best you'll be able to do.
Regarding your "if" statement. You can't treat a datacapture address like a file path. "/../" does *not* mean go up one level in the tree. What you'll need to do for that is to use some kind of string manipulation (I recommend regex) to construct the path to the question from the path to the answer.
Jonathon
Independent Interwoven Contractor
BlockwiseOutput.dcpackage
In Next story frame.png
gururaj
if(IWDatacapture.getItem(Caption.getName()+"/../Item_Image").value == "");
{
Caption.setValue=" ";
alert("Add the Image first");
}
There was similar code in FormApi html.
TSformapi/formapi/formapi_12.html#SC12
This is in addressing Addressing Parents and Siblings.
They have used "/../" to access the fields.
Please send if there are alternate solutions
Addressing Parents and Siblings
For this custom DTD:
<!ELEMENT b (e, f)>
<!ELEMENT e (#PCDATA)>
<!ELEMENT f (#PCDATA)>
That generates DCRs like this:
<b>
<e>This is e</e>
<f>This is f</f>
</b>
Then the following userscript code returns the item object that corresponds to the element e:
item = IWDatacapture.getItem("/b/e");
To get the parent item that corresponds to the element b, use the `..' notation:
parent = IWDatacapture.getItem(item.getName() + "/..");
To get the sibling item that corresponds to the element f:
siblingItem = IWDatacapture.getItem(item.getName() + "/../f");
export_settings.png
JonathonG
Oops, you're right. Sorry about that.
Did my comments about the "onClick" make sense? Could you make your code work using onChange?
Jonathon
Independent Interwoven Contractor