Specify Value in Dynamic Dropdown List

Avatar

Avatar
Level 2
foleyb77
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
foleyb77
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

0 solutions
View profile
foleyb77
Level 2

08-01-2009

I have a dynamic drop down list populated by a javascript array<br /><br />jsColorData - Variable (Contents Below)<br /><br />function getColors(colorField){<br /> for(var a=0;a<colorArray.length;a++){<br /> colorField.addItem(colorArray[a][1]);<br /> }<br />}<br /><br />var colorArray = new Array(<br />new Array("1", "Red"),<br />new Array("2", "Green"),<br />new Array("3", "Blue")<br />);<br /><br />Color Dropdown List - Initialize event<br />jsColorData.getColors(this);<br /><br />//All of the above works! But I need the form output to have the key and not the value.<br /><br /><?xml version="1.0" encoding="UTF-8" ?> <br /><form1><br /><pg1><br /><Color>Blue</Color> //I need the value here to be "3" instead of "Blue"<br /></pg1><br /></form1><br /><br />Is there a function or someway to get my desired result?

Replies

Avatar

Avatar
Level 2
foleyb77
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
foleyb77
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

0 solutions
View profile
foleyb77
Level 2

08-01-2009

I forgot to mention that on the object binding tab there is a checkbox - Specify Item Values. I cant check the box because the list is not being populated from the object window, it is dynamic, My list of values is long(350) which is why I dont want to enter them and prefer to use the an array and javascript.

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

08-01-2009

When you add the item to the list you can spedify both values in your addItem statement(DD1.additem("1", "Blue"). Now if you want the "1" then use fieldname.rawValue, if you want the "Blue" then use fieldname.formattedValue.

Avatar

Avatar
Level 2
foleyb77
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

0 solutions
View profile

Avatar
Level 2
foleyb77
Level 2

Likes

0 likes

Total Posts

24 posts

Correct reply

0 solutions
View profile
foleyb77
Level 2

08-01-2009

Thank you so much Paul! Just one quick note I discovered.

its actually (DD1.additem("Blue", "1")

I had to change event from "Change" to "Exit" but no big deal.



Thanks again!