Skip to main content
bebarth
Community Expert
Community Expert
Nov 7, 2020 6:35 PM UTC
Answered

Building a dropdown list in a dialog box

Hi,

I’m writing a script for a dialog box including a dropdown list.

Items of the list are depending on some variables, so I build a script line like that (here for 5 variables):

var theList="dialogBox.insertEntryInList({\"LCou\":{"+var1+": -1}});dialogBox.insertEntryInList({\"LCou\":{"+var2+": -1,"+var3+": -1,"+var4+": -1,"+var5+": -1}});";

then, in the dialog box building, I recall this string:

eval(theList);

That works fine as long as there is no space in the text of each variable, but that doesn’t work anymore as soon as there is a space.

I tried to replace this character by the Unicode character, the result is the same.

At the moment, my solution is to replace each space by an underscore…

Does anyone get an idea to solve that? I would prefer display a space when needed.
Thanks in advance.

This topic is closed to new replies. Start a new post to keep the conversation going.
Bernd Alheit
Bernd AlheitCorrect answer
Community Expert
Nov 8, 2020 7:19 PM UTC

No. Use this:

+ "\"" + var1 + "\"" +

4 replies

Bernd Alheit
Community Expert
Community Expert
Nov 8, 2020 6:28 PM UTC

At begin and end of each variable add "\"".

Translate
bebarth
Community Expert
bebarthCommunity ExpertAuthor
Community Expert
Nov 8, 2020 7:12 PM UTC

Thank you for your answer, but like that "var1", "var2", etc are the name of each item...

Translate
Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
Nov 8, 2020 7:19 PM UTC

No. Use this:

+ "\"" + var1 + "\"" +

Translate