Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Afif Abu Bakar
Drop down, remove bracket
November 5, 2012 8:59 PM
Answer

Afif Abu Bakar

Rank: Junior Member

Posts: 25

Join Date: August 6, 2012

Recent Posts

Hi,

I'm having a problem when try to get the value for the drop down in dynamic link list.

Below is my code to get the value for drop down.

1
2#set ($fields = $record.getFields())
3#set ($body = $fields.get("body"))  //here is the line I used to get value for dropdown
4
5 #if ($body.value == "value1")
6       ///do something
7 #end


Right now the if else statement is not working because the output for $body.value is ["value1"] instead of just "value1".

Is it correct the way I get the value for the dropdown? Kindly help me with this please.

Thank you.
Afif Abu Bakar
RE: Drop down, remove bracket
November 6, 2012 10:45 AM
Answer

Afif Abu Bakar

Rank: Junior Member

Posts: 25

Join Date: August 6, 2012

Recent Posts

Nobody can help with this?
Tyler B
RE: Drop down, remove bracket
November 13, 2012 7:50 AM
Answer

Tyler B

Rank: New Member

Posts: 1

Join Date: November 9, 2012

Recent Posts

I ran into the same issue this week. It appears that some of the values for certain fields are being stored as ["value"]. In my form, the text and text box output are displayed correctly, but others such as radio and drop down are displayed with the extra characters. If you pass these variables to javascript and then display, they lose the brackets and quotes.

<script>
var javascriptvariable = ${velocityvariable};
</script>

There are various options for displaying the variables once you get them to javascript. Check out W3 Schools and Stack Overflow for more discussion on this.

http://www.w3schools.com/jsref/prop_html_innerhtml.asp
http://www.w3schools.com/jsref/met_doc_write.asp
http://stackoverflow.com/questions/4537963/javascript-what-are-alternatives-to-document-write
Afif Abu Bakar
RE: Drop down, remove bracket
November 20, 2012 6:44 PM
Answer

Afif Abu Bakar

Rank: Junior Member

Posts: 25

Join Date: August 6, 2012

Recent Posts

Tyler B:
I ran into the same issue this week. It appears that some of the values for certain fields are being stored as ["value"]. In my form, the text and text box output are displayed correctly, but others such as radio and drop down are displayed with the extra characters. If you pass these variables to javascript and then display, they lose the brackets and quotes.

<script>
var javascriptvariable = ${velocityvariable};
</script>

There are various options for displaying the variables once you get them to javascript. Check out W3 Schools and Stack Overflow for more discussion on this.

http://www.w3schools.com/jsref/prop_html_innerhtml.asp
http://www.w3schools.com/jsref/met_doc_write.asp
http://stackoverflow.com/questions/4537963/javascript-what-are-alternatives-to-document-write


Dude, a big thank you for you!! emoticon