cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the Selected index in a Drop Down List?

Former Member
0 Kudos

Dear all,

I have populated one Drop Down list using Java code. Now,base on the selection of this drop down list,i need to change another field's value accordingly..how should i do that? I;ve tried various method to get the index of the current selected item in the drop down list but to no avail...can someone please shed some lights...thank you!

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Lee,

You can have a work around like: bind the internal table (which consists of Materials and their respective Price's) in the Adobe Form by creating a separate table in the Layout Designer and make it's pressence as hidden. As usally bind the drop down list also which consists of all the materials. Now in the exit event of the Material Drop Down loop this hidden table and get the materials price and place it in the current row where ever it is required. For this some scripting effort is required as need to loop a table and need to get the value and again place it in the current row of the existing table.

Hope this may solve your issue.

Regards

Pradeep Goli

chintan_virani
Active Contributor
0 Kudos

Joan,

Any specific reason on why you want the index, because instead of that on the exit event of Drop-down write following in JavaScript.

if(ddList.rawValue = "somevalue") // insert your condition here
{
   // do domething
   TextField.rawValue = "Hi Joan";
}

Chintan

Former Member
0 Kudos

Hi Chintan,

I need to change the price according to the material selected in the dropdownlist....any idea how should i approach this? Thank you

chintan_virani
Active Contributor
0 Kudos

Joan,

Put if else conditions as per your business logic and the code I gave should work for you.

Just FYI ddList is name of my drop-down.

if(ddList.rawValue == "Mat1")
{
   NumericField1.rawValue = "12.0"; // NumericField1 is name of my price field.
}
else if(ddList.rawValue == "Mat2")
{
  NumericField1.rawValue = "2.0"; 
}
else
{
  NumericField1.rawValue = "1.0"; 
}

Chintan

Former Member
0 Kudos

hi Chintan,

this is not wat i am looking for as i duno the unit price for each material. thx

nikhilkup
Active Participant
0 Kudos

ARE YOU WORKING ON HCM FORMS OR ITS THRU WEB DYNPRO ?

Former Member
0 Kudos

hi Nikhil , I working through WD Java

nikhilkup
Active Participant
0 Kudos

ok now tell me whether the next value will be some hard code values or it will come from database?

Former Member
0 Kudos

Hi Nikhil ,

the next value come from database.

actually the record goes like this, it is a table , say

Mat_ num desc price

A001 book 3 .0

A002 pencil 2.5

i will have more than 20 materials. In the java wdinit, i have already populate all the mat_num into the drop down list

and these drop down list are selectable at each row in the table which resides in the Adobe form.

now for each row, when they select the mat_num, i need to display the correct price at that particular row.

any idea how can i implement this? many thanks

nikhilkup
Active Participant
0 Kudos

Hi Lee,

As far i know you need to trigger an event and for that you need a button in the form which is linked to the event. then in the method ONACTIONCLICK you need to write the code. In your case tricky part will be to decide where to put the button.

Edited by: Nikhil Poojari on Aug 27, 2009 8:55 AM

Former Member
0 Kudos

Hi Nikhil ,

I already have all the data in the data object..i just need to know how to get the selected index or any other work around?? i do not need a button to trigger it

nikhilkup
Active Participant
0 Kudos

I am not sure of the index, so you mean to say when you select one material the corresponding rate should be displayed in the table. will it be possible to show the description and the rate in the drop down of material, so you wil have only one field in the table which will contain all the three fields.

even if you get the index what will you do with that ?

Edited by: Nikhil Poojari on Aug 27, 2009 9:26 AM

Former Member
0 Kudos

it is ok,forget bout it. I will figure it out myself. thx

Former Member
0 Kudos

Have you tried this.selectedIndex in Adobe Javascript?

Regards,

Subramanian V.

Former Member
0 Kudos

Hi Subramanian,

I've tried this, but it's not giving me any value. any example of using this? i use it in the exit event of the drop down list. Thank you.

nikhilkup
Active Participant
0 Kudos

Lee, for my knowledge i wanted to know how you would use the index value further ?

Former Member
0 Kudos

I have used this and it works absolutely fine.

It only lets me know the index number and not the value.

I have also used this in the exit event of the dropDown element.

xfa.host.messageBox("You have selected = " + this.selectedIndex);

Regards,

Subramanian V.

Former Member
0 Kudos

Hi,

id you get selectedIndex of drop-down list. i am having the same problem. Thx