Forum Discussion
Hi pp_01
You should be able to store the JSON object against a Freemarker variable that will create a hashmap and allow you then to access the properties.
There are several ways you can do this but I've found this blog article - Working with JSON in Freemarker covers them quite well.
Let us know how you get on.
Thank you for answering Robert :smileyhappy: . I have looked at the link you mentioned and have tried something on my page. It shows no error in the preview but on the page, I'm not getting the required functionality. In the select element, options are there but nothing is happening when I'm clicking on them. Is there anything that I'm forgetting? Apart from this what is needed in the code so that I can read the JSON if I've uploaded it in assets of my dev environment? How can I get the URL from the JSON? Do I need to use any REST call for that?
<#assign countries = [ { "name":"Argentina", "url":"https://testurl.com" }, { "name":"Australia", "url":"https://testurl.com" } ]
> <select name="countrySelect" id="countrySelected"> <#list countries as country> <option value ="${country.url}" target="_blank">${country.name}</option> </#list> </select>
- Payal8 years agoDirector
Hi pp_01,
You have to use onchange attribute in select statement as following:
<select name="countrySelect" id="countrySelected" onchange="location = this.value;">
<#list countries as country>
<option value ="${country.url}" target="_blank">${country.name}</option>
</#list>
</select>LMK if this works for you.
Thanks,
Payal
Related Content
- 3 months ago
- 10 months ago