cancel
Showing results for 
Search instead for 
Did you mean: 

onValueHelp call Javascript Function

alberto_colonna
Participant
0 Kudos

Hi,

I have created an inputfield with a f4-button.

If the button is clicked a javascript function shall be called.

The function has an input parameter.

I tried thid but it doesn't work. I think that the error is located in the last line when

I try to call the function.:

<htmlb:inputField id = "descr_<%= lv_counter %>"

value = "<%= ls_comp-task_descr %>"

maxlength = "40"

submitOnEnter = "FALSE"

showHelp = "X"

onValueHelp = "call_f4_help('descr_' + <%= lv_counter %>);" />

can you help me?

Best regards

Alberto

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Alberto,

I guess that there is some issue with the ID not fitting. Therefor I'd suggest the following:

Define 2 variables on top of your view/page:


data: lv_id type string,
        lv_script type string.

Insert directly before your inputfield the following:


<% lv_id = lv_counter.
      condense lv_id no-gaps.
      concatenate 'descr' lv_id into lv_id.
      concatenate 'call_f4_help("' lv_id '");' into lv_script. %>

And change the inputfield to:


<htmlb:inputField id = "<%=lv_id%>"
value = "<%= ls_comp-task_descr %>"
maxlength = "40"
submitOnEnter = "FALSE"
showHelp = "X"
onValueHelp = "<%=lv_script%>" />

There are 2 things you need to be aware of:

1. In case you use Controller + view do not use underscores in the ID's. Underscores are used to ensure unique ID's in case you use subcontroller.

2. In case you use that on a subcontroller you need in addition to the upper coding:

Change the controller class of the view to CL_BSP_CONTROLLER2.

Change the coding before the inputfield to


<% lv_id = lv_counter.
      condense lv_id no-gaps.
      concatenate 'descr' lv_id into lv_id.
      "add the call to get the correct ID from the controller for the script
      "the inputfield does this call automatically during rendering
      lv_script = controller->get_id( lv_id ).
      concatenate 'call_f4_help("' lv_script '");' into lv_script. %>

Hope that helps.

Best Regards

Michael