Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Javascript and BSPs

Former Member
0 Likes
613

I have a BSP application where I am displaying the contents of a table on a BSP page, and allowing the user to change the table items. I also want to add some javascript to update some of the fields in the table, but I am having trouble with the indexes.

Here is a sample of my code:

<% loop at t_qtitems into w_qtitems. %>
<input type="text" name="t_qtitems[<%=sy-tabix%>].rqmult"
    size="2" maxlength="5" value="<%=w_qtitems-rqmult%>">
<% endloop. %>

I want to add a button to use javascript to update the input text fields using javascript. However, when I view the web page, I see this as the field name:

<input type="text" size="2" maxlength="5"
  name="t_qtitems[1 ].rqmult">

When I try to use javascript to update this input field, for example:

frmInput.t_qtitems[1 ].rqmult.value=100;

I receive a javascript error "frmInput.t_qtitem.1 is null or is not an object". How do I change the indexed items from this table using javascript?

4 REPLIES 4
Read only

Former Member
0 Likes
576

Denise,

Try with t_qtitems[1 ].rqmult.value=100;

Thanks

Kam

Read only

0 Likes
576

That doesn't work. This is javascript where I am doing this change, so I need to reference the html form where the field that I am trying to update resides.

Read only

Former Member
0 Likes
576

Hi,

Try with

frmInput.elements["t_qtitems[1 ].rqmult"].value=100;

Thanks,

Amara.

Read only

Former Member
0 Likes
576

Hai Hartman,

I have faced a similar problem,Here when u are naming

the ID or names of input fields make sure that does not

contain "],[,,." special characters.

Make sure you specify the id of the input field.

I am including a sample program where I am updating a

hidden field with the value entered in the input prompt

with javascript .

Page with flowlogic


<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<htmlb:content design="design2003" >
  <htmlb:page title="Input prompt " >
  <script language="JavaScript" type="text/javascript">
                 function save_input_prompt()
                 {
                  var varient_name = prompt("Save Varient as ?","");
                   if (varient_name == null )
                   return false;
                   else if (varient_name == "" || varient_name == " ")
                    {
                      alert("Enter a valid input");
             	        return false;
                    }
                   document.mainform.if_varient_name.value =varient_name;
                   alert( document.mainform.if_varient_name.value );
                  return true;

                 }
      </script>
    <htmlb:form id="mainform" >

      <htmlb:inputField id    = "if_varient_name"
                        value = "abc"
                        visible = "false" />
      <htmlb:button id            = "save_query_open"
                    text          = "Save as"
                    onClick       = "EVT_SAVE_QUERY"
                    onClientClick = "if(!save_input_prompt()) htmlbevent.cancelSubmit=true;"
                    tooltip       = "Save Query" />
    </htmlb:form>
  </htmlb:page>
</htmlb:content>

input processing .


DATA lv_string TYPE string.
lv_string = request->get_form_field( 'if_varient_name' ).

DATA: data TYPE REF TO cl_htmlb_inputfield.
data ?= cl_htmlb_manager=>get_data( request      = runtime->server->request
                                    name         = 'inputField'
                                    id           = 'if_varient_name' ).
IF data IS NOT INITIAL.
  lv_string = data->value.
ENDIF .

Put a break pointer in inputprocessing to check if you

can retrive the value properly. I have included two ways of retiving

value from the form fields.

Hope this would help you.

Finally,

This is the wrong forum that u have posted this question.

There is a seperate forum for BSP

best regards,

venkatesh.