This code allows me to write out the various "departments" or checkboxes that an admin has selected. example: Department 1, Department 2, Department 3
That works fine... for TEXT But I also want to pull the VALUES of these checkboxes in a different section, as I illustrated in my first picture. That would give me a result like: 78 79 85 (notice no commas and these are the numeric VALUES coinciding with the TEXT)
It just returns ALL the checkbox options.. in TEXT format. Both of which are not what I am looking for. I just want to be able to pull the VALUES of the checkboxes that are active inside my loop. I was hoping that preValue would be the direction to look... but I seem to be striking out.
I haven't been able to find any examples on the forum so far. Any help would be appreciated.
When I use this code above it exports all the numbers for the checkboxes... but ALL of them, not the ones that are selected for that item. example: 876668697071727374239240241242243244245246248
Also there are no spaces between the numbers. What I would like is: 87 66 68......
<preValues><preValue id="87">Dean's Office</preValue><preValue id="66">Communication Sciences and Disorders</preValue><preValue id="68">Criminal Justice</preValue><preValue id="69">Health Professions</preValue><preValue id="70">Legal Studies</preValue><preValue id="71">Health Management and Informatics</preValue><preValue id="72">Public Administration</preValue><preValue id="73">Doctoral Program in Public Affairs</preValue><preValue id="74">Social Work</preValue><preValue id="239">Undergraduate Student Services</preValue><preValue id="240">Center for Autism and Related Disabilities</preValue><preValue id="241">Center for Community Partnerships </preValue><preValue id="242">FAAST Assistive Technology Center</preValue><preValue id="243">Center for Public and Nonprofit Management </preValue><preValue id="244">Florida Center for Nursing</preValue><preValue id="245">Florida Institute of Government at UCF</preValue><preValue id="246">Communication Disorders Clinic</preValue><preValue id="248">Instructional Support and Technology</preValue></preValues>
I made a test and looked at this and all that is stored in the Umbraco.config is the texr value and not the prevalue id with no easy way to get it back, you could search on the text value and find the pre-value id but you don't know that the text values are unique. All round a fairly ugly approach that would be tricky and i think bad.
However that doesn't need to be the end of the story. Is it possible for you to use a different control?
My suggestion would be rather than to store this data in the pre values of a check box list (where it is hard to maintain) could you store it in content (easier to maintain) and then use an XPath Check Box List to access it. There are a number of ways to approach this. Happy to expand on this if it is of interest?
As a side note, the umbraco.library extensions are very helpful for XSLT operations. .NET uses XSLT 1.0 and is limited, that is why extensions can be such a life-saver. If you are planning to keep using XSLT for awhile, you should learn how to add your own custom extensions to the fold. That way if you know it can be done in C#, you can just write an extension and do all the dirty work there.
Retrieve Checkbox VALUE not TEXT with XSLT
Hello everyone.
I'm trying to get the VALUE of the checkboxes that are checked. NOT the TEXT
How can I pull those using XLST?
I'll also want to use: umbraco.library:Split so that I can render a result like: 75 78 80
Right now everytime I try to use: umbraco.library:GetPreValueAsString I get an error: Error parsing XSLT file:\xslt\MyFile.xslt
Thank you in advance!
Hi Farmfreshcode
What does the stracktrace say if you add ?umbdebugshowtrace=1 to your url where the xslt is supposed to render? Perhaps it contains the answer?
It would also be nice to see some of your code.
/Jan
Good afternoon Jan,
I didnt see anything in the showtrace that would point to an answer.
Right now I am using the following code in order to display the TEXT of these checkboxes.
This code allows me to write out the various "departments" or checkboxes that an admin has selected.
example: Department 1, Department 2, Department 3
That works fine... for TEXT
But I also want to pull the VALUES of these checkboxes in a different section, as I illustrated in my first picture.
That would give me a result like: 78 79 85 (notice no commas and these are the numeric VALUES coinciding with the TEXT)
If I write something like:
It just returns ALL the checkbox options.. in TEXT format. Both of which are not what I am looking for. I just want to be able to pull the VALUES of the checkboxes that are active inside my loop. I was hoping that preValue would be the direction to look... but I seem to be striking out.
I haven't been able to find any examples on the forum so far. Any help would be appreciated.
Hi FarmFreshCode
Have you been reading this post by Lee? http://www.blogfodder.co.uk/2009/12/22/getting-dropdown-list-datatype-values-in-your-html
I think you should perhaps just write <xsl:value-of select="@id" />
Otherwise try to see what XML is returned in your topicList variable by doing this
<textarea>
<xsl:copy-of select="$topicList" />
</textarea>
What does the returned XML look like? The numbers should be in there.
/Jan
Hi Jan,
Well that advice helped a little.
When I use this code above it exports all the numbers for the checkboxes... but ALL of them, not the ones that are selected for that item.
example: 876668697071727374239240241242243244245246248
Also there are no spaces between the numbers. What I would like is: 87 66 68......
I assume that this is the problem with calling
GetPreValues('1637')
the dataType ID (1637) instead of what I want
I just need to figure out how to do that... hmmmm
Hi Jan,
When I do your XML test I get results like this:
Comment author was deleted
Are you trying to out put what is selected by the admin?
If so please paste in your xml from the umbraco.config (just the relevant part) and I can help you out.
Hi Kevin. Thanks, I would appreciate your help as well...
As far as the XML goes.. here is a relevant section of the output:
I put together a graphic for what I am trying to do...
But ultimately my goal is to have something in my XSLT file that looks like this:
which would output the VALUE number of the checkbox and NOT the TEXT
But I am at a complete loss at how to reach the VALUE number of these checkbox items inside the loop.
Thank you!
I think the short answer is that you can't.
I made a test and looked at this and all that is stored in the Umbraco.config is the texr value and not the prevalue id with no easy way to get it back, you could search on the text value and find the pre-value id but you don't know that the text values are unique. All round a fairly ugly approach that would be tricky and i think bad.
However that doesn't need to be the end of the story. Is it possible for you to use a different control?
My suggestion would be rather than to store this data in the pre values of a check box list (where it is hard to maintain) could you store it in content (easier to maintain) and then use an XPath Check Box List to access it. There are a number of ways to approach this. Happy to expand on this if it is of interest?
Ok, well I was afraid that would be the answer. Guess I'll think of a different way to tackle this problem.
Thanks a lot for responding..
have you tried the following:
you could ofcourse wrap that in a variable etc :-)
Well HIGH FIVE to Gerty Engrie! This works to pull the numbers pefectly...
THANK YOU!!!
Comment author was deleted
Good deal!
As a side note, the umbraco.library extensions are very helpful for XSLT operations. .NET uses XSLT 1.0 and is limited, that is why extensions can be such a life-saver. If you are planning to keep using XSLT for awhile, you should learn how to add your own custom extensions to the fold. That way if you know it can be done in C#, you can just write an extension and do all the dirty work there.
this solution gives you what you want yes
but it does assume that all the text values are unique
which I guess they are so no worries
was very impressed by Jeavon's talk at the recent London Meetup about property value editors
http://our.umbraco.org/Documentation/Extending-Umbraco/Property-Editors/PropertyEditorValueConverters
if there were one of these for the check box list and you could access this as XML from an XSLT extension
that would solve this problem nicely
more here too http://www.slideshare.net/JeavonLeopold/what-theheck
is working on a reply...