Back

Pulling a list of content into a custom field

Description

This code will pull a list of content into a custom field and create a select box for each result. Onchange it will set the value of the custom field.

Code

## Pull list of content into Custom Field

<select id="fakeSelectId" dojoType="dijit.form.FilteringSelect" onchange="setCustomValue()">
	#foreach($con in $dotcontent.pull("+structureName:Products +(conhost:48190c8c-42c4-46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST)",10,"modDate desc"))
		<option value="$con.tickerSymbol">$con.title</option>
	#end
</select>

<script>
	function setCustomValue(){
		
		//Gets the value of the selects field
		var y = dijit.byId("fakeSelectId").getValue();
		
		// Sets the custom field value in this case the field was called related products
		dojo.byId("product").value = y;
	}
</script>