Getting Dropdown List DataType Values In Your HTML

I recently had a need to show a value from a Drop Down DataType I had created in my Umbraco UI - The backend users were using the drop down to create content, but I needed people to be able to use the values in the front end to also submit content via my HTML pages.

In this tutorial I'll show how to recreate the dropdown list DataType in the front end - To get the DataType values you need to use a method from the umbraco.library() called GetPreValues() where you need to pass in the ID of the DataType [more]

  1. umbraco.library:GetPreValues('THEID')

To get the ID you just need to hover over your DataType and in the footer of your browser you can get the ID (For example this one has an ID of 1102)

Capture

Once you have the ID you can recreate the <select> (Drop down list) by using the code below

  1. <select name="eventType" id="eventType" >
  2. <option value="0">Please Choose</option>
  3. <xsl:variable name="topicList" select="umbraco.library:GetPreValues('1102')" />
  4. <xsl:for-each select="$topicList//preValue" >
  5. <option value="{@id}" >
  6. <xsl:value-of select="current()" />
  7. </option>
  8. </xsl:for-each>
  9. </select>

If you didn't want to have the ID as they value for the option you can also do

  1. <option value="{current()}" >
  2. <xsl:value-of select=

Post a comment