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)
Form API + hide fields
herald10
Hi,
I have a DCT that needs to display/hide a list of fields based on a radio button that is selected. I register a handler onItemModified event and everything works fine. But the problem is when I create a new DCR, it is displaying all the fields even when I select one of the values specified for the radio button. Can this be possible using FormAPI? once again the problem is "when the DCR is created for the first time a list of items are to be either hidden or displayed based on the value of a radio button that will be selected by the user". Any help please...
Thanks a lot in advance
Find more posts tagged with
Comments
mk2004
You can control this using FormAPI. There are three parts actually,
1. Controlling visbility when the DCR opens (onLoad)
2. when the item changes
3. while saving (Validations)
for your case, check the value of the radio buttons and restrict the visibility of the fields while the DCR loads.
Sri
Hi,
Yes. You can do this with FormAPI. I believe the example userscript/position (shipped with Formspublisher) demonstrates how to do something similar. Post any other question you have once you've gone through the example.
Sri
herald10
Thanks for the response. But the problem is when the page loads for the first time, when a new DCR is being created, theres no value selected for the radio button, so the DCT displays all the fields. Is there a way to do it?
Adam Stoller
In the DCT - define the fields to be hidden - and then use the FormAPI code associated with the radio-buttons determine whether they should be exposed (and/or re-hidden).
Right now, it sounds like your DCT is written such that the default attribute for these fields is exposed - just switch it around in the DCT and everything else that you already have written for hiding/exposing them should work as-is.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Sri
I think you can hide the list of fields in when the form is loaded (in the init() function or onFormInit() handler()). Then when the user selects an option in radio button, your FormAPI script can keep the list of fields hide --or-- make them visible. Does that work?
herald10
Goti,
Those fields can't be hidden. Because user needs to be able to see those fields(based on the radio button he selects). Those fields are there for the user to enter some text in it. Please correct me if I am wrong. Is there any other way to do it.
Thanks
Adam Stoller
Now I'm confused.
herald10 04/07/04 09:56 PM
... once again the problem is "when the DCR is created for the first time a list of items are to be either hidden or displayed based on the value of a radio button that will be selected by the user"
herald10 04/08/04 01:38 PM
Thanks for the response. But the problem is when the page loads for the first time, when a new DCR is being created, theres no value selected for the radio button, so the DCT displays all the fields. Is there a way to do it?
herald10 04/08/04 01:57 PM
Those fields can't be hidden. Because user needs to be able to see those fields(based on the radio button he selects). Those fields are there for the user to enter some text in it. Please correct me if I am wrong. Is there any other way to do it.
In order to hide the fields when the DCT is first loaded - you can either designate that the fields are hidden by default *or* hide them as part of the
init()
function via FormAPI.
As long as you already have code that hides/exposes these fields based on selecting radio-button items (or whatever) - that code should continue to work as-is - all you're doing is changing the initial default behavior.
You
might
need to add code to the
init()
function (or called from within it) that checks to see if the radio-button has a [non-default] value selected and, if so, runs the code to expose/hide the assocaited fields.
Does
this
accurately reflect what you are trying to do?
What part of this does not work?
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
herald10
Ghoti,
Sorry for the confusion.
When the DCT form loads for the first time, the radio button has no value selected. right? init() function can handle when theres any value associated with that radio button. But in our case it does not have any value. The user then selects one value. At that point, based on the selected value, certain fields(items) are to be hidden. Is this possible?
Hope that cleared up the confusion.
Thanks
Adam Stoller
Yes that's possible - I thought this was discussed earlier, or we all assumed you had this part of the problem dealt with.
FormAPI allows you to put event handlers on items like radio-button fileds, and this would in turn trigger a javascript function that would set (or clear) the 'hidden' attribute on other fields based upon what value came in for the field that was changed.
There are some examples that ship with the product and there is documentation on your TS server (
http://servername/iw/help/tst/formapi
) - and quite a fair amount of code snippets and stuff floating around in these forums. You should be able to put it all together from that.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
civ3
Hi herald10
I'm not sure if you have found the solution to this or not. You have already had a function to show/hide certain controls on the form depending on the state of a radio buttion. You can change that function to show all fields, I assume, if no selection on the radio button has been done by the user. I think the return value should be null. Then call this function when the form is loaded. This should do the trick you want.
civ3.
civ3
Hi ghoti
" In order to hide the fields when the DCT is first loaded - you can either designate that the fields are hidden by default *or* hide them as part of the init() function via FormAPI."
When you say designate the fields as hidden, do you mean use hidden fields for them? Is it possible to show hidden fields afterwards? I'm interested in this because I want to make certain fields not shown on the form by default when the form is loaded without using Form API.
Best regards,
civ3.
Adam Stoller
I'm not sure off the top of my head - but if you're developing some templates - now is the time to test it out and verify whether or not it works.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Just a quick note that TS6.5 provides additional FormAPI capability to do what it sounds like you are looking for. You can view a recent webcast on this topic here:
http://devnet.interwoven.com/site.fcgi/webcasts/docs/webcast-recordings.html#webcast04-23
regards,
lissa