cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a ABAP View atribute into a javascript func as a parameter

Former Member
0 Kudos

Guys,

This must be really simple ,but I am missing something

I need to pass a view attribute lv_name into a javscript

function written in the view.

e.g

function do_something(name) {

}

My call looks line do_something(lv_name) on a onClientclick of a button.But that does not work.

Appreciate any input.

Thanks,

Manoj

Accepted Solutions (1)

Accepted Solutions (1)

thomasalexander_ritter
Active Contributor
0 Kudos

Hi Manoj,

the coding in the view should look like (no need for a hidden field):

do_something(<%= lv_name %>);

regards

Thomas

Message was edited by: Thomas Ritter

Former Member
0 Kudos

Hai,

This is a sample where I am passing a variable to the javascript function that I am calling .

[code] <xhtmlb:toolbarLink id = "TBAR_LINK_RESULT_PERS"

text = "<%= otr($tmp/ipcb_rcn_personalize) %>"

reference = "javascript:do_myjavascript( '<%= zcl_header=>mc_appl_name %>','TBL_RCN_HDR' );" />

[/code]

regards,

Venkatesh.

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks everybody,

this format : function do_something('<% =var %>')

works fine.

thomasalexander_ritter
Active Contributor
0 Kudos

Hi,

nice to hear that you got it working could you please mark this topic as solved, thanks.

regards,

Thomas

Former Member
0 Kudos

hi,

Add a hidden field in your view page and assign its

value = "<%=name_of_page_attribute%>"

where "name_of_page_attribute" is your page attribute.

then access this attribute inside your javascript code

using:

var asd = document.form[0].hidden_field_name.value;

now you will have the value of page attribute in variable asd.

hope this helps you,

Regards,

Hemendra