‎2005 Nov 16 3:34 PM
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?
‎2005 Nov 16 3:49 PM
‎2005 Nov 16 4:15 PM
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.
‎2005 Nov 17 5:45 AM
Hi,
Try with
frmInput.elements["t_qtitems[1 ].rqmult"].value=100;
Thanks,
Amara.
‎2005 Nov 17 6:10 AM
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.