cancel
Showing results for 
Search instead for 
Did you mean: 

Getting selected value from dropdownListBox during onClientSelect?

former_member211904
Participant
0 Kudos

I would like to do implement some client-side logic in a BSP application. When the user selects a value in a dropdownListBox, I need to get the selected value.

I thought I can implement a function for the onClientSelect parameter, but this does not return the current DOM element.

How do I get at the selected value? Will this also work for other derivatives like THTMLB?

Thanks,

Martin

Accepted Solutions (0)

Answers (1)

Answers (1)

athavanraja
Active Contributor
0 Kudos

Search the forum, this has been discussed many a times before.


<htmlb:dropdownListBox id                = "DDLB1"
                             nameOfKeyColumn   = "NAME"
                             nameOfValueColumn = "VALUE"
                             table             = "<%= tab1 %>"
                             onClie ntSelect    = "java script: dd = doc ument.getElem entById('DDLB1'); al ert(dd.value);"
                             width             = "150" />

former_member211904
Participant
0 Kudos

Hello Durairaj,

This does not seem to work, because SAP prepends its own identifier to the ID you specify, so "product_type" can become

"C8_W24_V25_V35_product_type" or something, and then the document.getElementByID returns null.

I am using THTMLB though, so I am not sure if this makes a difference.

Regards,

Martin

former_member211904
Participant
0 Kudos

I managed to resolve the issue. After doing some debugging with Firebug, I found that inside my javascript code fragment, I have access to a htmlbevent object, which contains information about the HTMLB event that was fired.

To get the selected value, I can do the following in the code fragment:

htmlbevent.srcElement.value

htmlbevent.srcElement returns the element from which the event originated, in this case my dropdownlistbox.