Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

DropDownList retrieve value instead of text

Avatar

Level 2

I'm currently using Adobe LiveCycle Designer 7.0

I have a DropDownList2 field..

In Object / Binding .. the default binding is set to normal

Specify Item Values is selected

Value Text

L           Long

M         Medium

S          Short

In the PDF preview when user selects the field .. you can see "Long" "Medium" "Short"

If user selects "Medium"... I want to display the value "M"

I'm not a heavy java user.. so I feel like I'm poking in the dark.. I've tried:

DropDownList2.rawValue;

xfa.event.newText;

DropDownList2.rawValue = xfa.event.newText;

In the change event, exit event, calculate event...

and many more .....

I wish I knew how to attach my file so that someone can see what I'm trying to do..

I just don't know what I'm missing here.

Thank you for your time.. in just reading this..

... Sherri

0 Replies

Avatar

Level 6

Not sure if this is what you're looking for:

Droplist contains Long

                         Medium

                         Short

empty text field 1

Script on the change event of the droplist

if (xfa.event.newText ==" ")

{TextField1.rawValue = " "}

if(xfa.event.newText == "Long")

{TextField1.rawValue = "L"}

repeat for other two options

Avatar

Level 2

I don't want to create a new text field..

I want to display the Value for the DropDownList field not the text..

If user selects "Long"  I want to display value "L"

Avatar

Level 2

I found this in "help"... But it doesn't work..or I'm missing something here

Obtaining the current value of a drop-down list or a list box

In order to retrieve the current value of a drop-down list or list box after a user has changed the current value, you must use the newText property of the event accessor. For example, to store the new current value in a variable, add the following script:

var myVar = xfa.event.newText

Avatar

Level 6

Email your form to "n_varma AT lycos.com" and explain me each action in steps like....

1. I select "Large" in the dropdown

2. Then "Large" should go away from the options list and "L" should appear as selected....

3. Then if user choose to select "Medium" now "Medium" should go away from the options list and "M" should appear as selected and since users choose to select other now "L" should be converted back to "Large"..........

Layout all your requirements perfectly.......you are not descriptive in your original posting.

Avatar

Level 2

(See attached file: dropdownlists.pdf)

My apologies for being descriptive in my original posting...

In my attached document, I'm working on the following

1. If, then, else

2. Global binding

3. Trying to figure out how to hide and display fields

4. Trying to display the value instead of text

#4.. Is the ultimate goal...

When user selects the dropdownlist ... all text values are displayed in a

list view such as "Large" "Medium" "Short"....

If user selects "Medium", "Medium" should go away from the options list

and display "M" which should be the value of "this.rawValue"

If user wants to change their minds and click on the lookup option... all

text values should display in list view... and say they select "Large",

"Large" should go away from the options list and display "L"...

I've been trying to work with the this.rawValue.... and not getting the

results that I want...

The other fields that I'm testing in 1,2,&3... I would like to have the

same function as option 4...

*********************************

I did find text in my help that stated:... This is exactly what I want..

But I can't get it to work.

Obtaining the current value of a drop-down list or a list box

In order to retrieve the current value of a drop-down list or list box

after a user has changed the current value, you must use the newText

property of the event accessor. For example, to store the new current value

in a variable, add the following script:

var myVar = xfa.event.newText

*******************************

I also found this once placed in Exit... I know for a fact that if you

choose "Medium" that the "this.rawValue" is "M".. however.. I can't get it

to be displayed in the dropdownlist field... Not that I really want a

message box to be displayed.. but this has assisted me in determining that

the "this.rawValue" is correct

xfa.host.messageBox(this.rawValue);

DropDownList2 = this.rawValue;

I hope that this information is helpful, If not, please let me know and I

can try to explain in a different way.

Thank you so much for your time..

... Sherri

From: Varma_LC <forums@adobe.com>

To: Sherri Heyde <sheyde@richlandcountyoh.us>

Date: 02/16/2010 12:20 PM

Subject: DropDownList retrieve value instead of text

Email your form to "n_varma AT lycos.com" and explain me each action in

steps like....

1. I select "Large" in the dropdown

2. Then "Large" should go away from the options list and "L" should appear

as selected....

3. Then if user choose to select "Medium" now "Medium" should go away from

the options list and "M" should appear as selected and since users choose

to select other now "L" should be converted back to "Large"..........

Layout all your requirements perfectly.......you are not descriptive in

your original posting.

Avatar

Level 6

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /> I tried my best based on your input. However there may be some tweaks necessary. Look at the code under "initialize, preOpen and exit" events.......comments included for your understanding. Check the attached dropdownlists_Updated.pdf

Also have to add a invisible textbox next to the Dropdown to get it working as we needed. Named the Dropdown as "TryDD" and textField "TryDDBackUp".

Now if you like it's functionality you can add invisible Textfield next to each dropdown and name DD and textfield to correlate and then copy code in "initialize, preOpen and exit" events and replace "TryDDBackUp" with the new name you gave in that context. Rest of the code should work with no changes for you. This is the most generic code I could come up with to minimize changes at your end.

Hope this works for you.....though there are better ways to deal with.

Good luck,

Avatar

Level 2

I'm sorry .. but I don't see an attachment to the last email.

From: Varma_LC <forums@adobe.com>

To: Sherri Heyde <sheyde@richlandcountyoh.us>

Date: 02/16/2010 03:17 PM

Subject: DropDownList retrieve value instead of text

Hi,<?xml:namespace prefix = o ns =

"urn:schemas-microsoft-com:office:office" />

    I tried my best based on your input. However there may be some tweaks

necessary. Look at the code under "initialize, preOpen and exit"

events.......comments included for your understanding. Check the attached

dropdownlists_Updated.pdf

Also have to add a invisible textbox next to the Dropdown to get it working

as we needed. Named the Dropdown as "TryDD" and textField "TryDDBackUp".

Now if you like it's functionality you can add invisible Textfield next to

each dropdown and name DD and textfield to correlate and then copy code in

"initialize, preOpen and exit" events and replace "TryDDBackUp" with the

new name you gave in that context. Rest of the code should work with no

changes for you. This is the most generic code I could come up with to

minimize changes at your end.

Hope this works for you.....though there are better ways to deal with.

Good luck,

Avatar

Level 6

This forum used to support attachments looks like not any more....that is the reason I asked you to email me and I did reply to your "richlandcountyoh" email address with same attachment. Let me know if have not received the attachment after you check the inbox.

Avatar

Level 2

Solution...

This is to all who have been trying to find an answer .. I'm using Adobe LiveCycle Designer 7.0.. I updated Adobe Reader to 9.1.3

This allows you to see the lookup field text for a field and place the value instead of text.. If user selected the wrong option.. User can go back and select another choice.

Thank you "chandra sekhara varma nimmagadda" for your assistance and patience!  My apologies for not closing this sooner.

... Sherri

.............................................

Create a hidden text field called "TryDDBackup"

Create a DropDown list field called "TryDD"

   Make sure that you specify item menus is checked and you have your Value and Text listed in the table..

   In my situation I had:

             L     Long

             M    Medium

             S     Short

Add the following code:

----- form1.#subform[0].TryDD::initialize - (JavaScript, client) -----------------------------------

var ddList = "";                         //variable to hold the list for this instance
                                         //xfa.host.messageBox(""+this.length)//to display totoal number of listed options in this dropdown
var numberOptions = this.length;         //to hold the value of number of items in the options list
TryDDBackUp.rawValue = ""               //set the related hidden textbox value to null
for (i=0;i<this.length;i++) {
                                 //xfa.host.messageBox(""+this.getDisplayItem(i));
ddList = ddList + "***" + this.getDisplayItem(i) + "~" + this.boundItem(this.getDisplayItem(i));
                                       //construscting value with display text and it's value to use later
}
TryDDBackUp.rawValue = ddList;        //now save the constructed value to related invisible textbox for future use.

this.clearItems();                   //will clear options list but we do not have to worry as we saved all the values
                                     //in the related invisible textbox. We will load them in "preOpen" event

----- form1.#subform[0].TryDD::exit - (JavaScript, client) -----------------------------------------

var selectedVal = this.rawValue; //currently selected value
this.clearItems(); //again clear list for this DD
this.addItem(selectedVal); //add new list item with the selected value for this DD
this.rawValue = selectedVal; //now force it to select the value again.

----- form1.#subform[0].TryDD::preOpen - (JavaScript, client) --------------------------------------

var preSelecteVal = this.rawValue;           //save the value incase it is being selected already
this.clearItems();                           //clear all the options
var stringList = TryDDBackUp.rawValue;       //get the constructed value from initilize event code
stringList = stringList.split("***");        //split the value to multiple list options

                                             //start loading list options
var listItem;                                //variable to hold temp values for each itration
for (i=1;i<stringList.length;i++) {
                                      //xfa.host.messageBox(stringList[i])
listItem = stringList[i];
listItem = listItem.split("~");      //prepare the display text and related value to load in to options list
this.addItem(listItem[0], listItem[1])
}

this.rawValue = preSelecteVal;               //load previously selected value if any