Home
TeamSite
How to access value of an Select Option's label?
semaphore
Is there an easy way to access the value of an option's label from within a presentation template? Here is the item in my DCT:
<item name="Topic">
<select required="t">
<option label="label a" value="value a" selected="t" />
<option label="label b" value="value b" selected="t" />
</select>
</item>
I want to the access value of the label (eg. "label a") that the user selected. I know how to acces an Option's value, but in this case I need to access the value of label as well.
Thanks!
Find more posts tagged with
Comments
Adam Stoller
Can you provide a bit more context - such as: are you trying to do this in FormAPI, or in a cgi-callout or in a workflow externaltask or cgitask script?
The answer may be differnent depending on such parameters
--fish
(Interwoven Senior Technical Consultant)
semaphore
I need to do this as part of a workflow where a user is working on a DCR. I want to capture the Option label's value in the presentation template when user is previewing or generating. This is not using FormAPI/CGI/External task.
Thanks
Adam Stoller
I don't have a lot of time right now - I'm not sure if there's a solution using PT tags, but you can always break into a bit of Perl and use TeamSite::XMLnode to access the information you want - or if you know XSLT you could probably use that too (not sure - haven't done too much with that stuff).
For more information on TeamSite::XMLnode - use perldoc or look at the on-line documentation in
http://ts_server/iw/help/tst/pt
Hope that helps
--fish
(Interwoven Senior Technical Consultant)
MattP
I don't think that would work. The label is used for the template, but it is never stored in the DCR. So in the DCR a year drop down would be <item name="startyear"><value>2003</value></item>. There is no sign of the label.
Then again, I am not an amethyst or anything so it may be possible. HAHA
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
jbonifaci
fish was referring to parsing the DCT and retrieving the label from there, I believe.
Just another thought, does the relationship between value and label exist anywhere outside of TeamSite? i.e. a db table? I'm assuming the value is being used to map to the label somewhere other than TeamSite. If so, just retrieve the label from wherever else the value to label mapping exists.
Jeff Bonifaci
nipper
it lives in the DCT, parsing that to find it is not trivial, but should not be rocket science either.
Now if TeamSite:
CRnode worked on a DCT, then it would be pretty easy. There are probable some XML parsing modules available. Checkout cpan.org
Andy
jbonifaci
If you decide to go the dct route and don't want to deal with parsing the dct you can post your dct here and what field(s) it is you are trying to retrieve the label for. Then myself or someone else here can give you a 1 line regex statement to strip the label out of the dct based on the value.
semaphore
Thanks for your responses folks! I chose an easy way to do this. In item's value attribute, I have both the label and value separated by a character. In the PT I split the value and get both the label and value.
Thanks for your time.