on ‎2005 Dec 19 9:31 AM
Hi BSP experts,
within my BSP form I had to use some javascript parts. I am not really familiar with javascript and have the following problem:
I created a javascript variable:
var name = document.getElementById('name').value;
Variable 'name' is filled by a form field, but now I have the problem to fill the hidden field with the variable value (I need that hidden field for data posting):
<input type = "hidden"
name = "NAME_LAST"
id = "NAME_LAST"
value = '"NAME"' />
In my example, the value of my variable is not considered, but it is only as string interpreted.
Best regards
Tom
Request clarification before answering.
Hi,
This sample code can be helpful to you,
<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>
<head>
<SCRIPT language="JavaScript">
function func()
{
<%
if flag is initial.
%>
var txt;
txt = "Hello";
document.formBody.if01.value = txt;
document.formBody.submit();
<%
endif.
%>
}
</SCRIPT>
</head>
<htmlb:content design="design2003" >
<htmlb:page title = " "
onLoad = "func()" >
<htmlb:form id="formBody" >
<htmlb:inputField id = "if01"
type = "string"
visible = "false"
size = "20" />
<htmlb:textView text = "<%= temp %>"
design = "EMPHASIZED" />
</htmlb:form>
</htmlb:page>
</htmlb:content>Thanks & regards,
Ravikiran.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use the following code
document.forms[0].elements[1].value = ' "name2" '.
if you have more than one form identify the form number and change the subscript of the array to forms[1] or forms[2] respt.
and similar case with elements[2] etc
if you dont know which elemnt is is then type the following code in your javscript.
var i = 0;
for(i=0;i<document.forms[0].elements.length;i++)
{
alert(document.forms[0].elements<i>);
alert(i);
}
here you will get the elemnt number.
then hard code the value of i
in your javscript.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Welcome to SDN Tom.
the stt.
var name = document.getElementById('name').value;
is to set the element (name) value to variable name.
you cannot just give the javascript variable anme in the value field. if you want to set the value for a input field thru javascript consider the following example.
<input type = "hidden"
name = "NAME_LAST"
id = "NAME_LAST"
value = "" />
<script>
document.getElementById('NAME_LAST').value = 'ABC' ;
</script>
the above script would set the value for the input field as 'ABC'.
if you want this to happen on particular action.(say a button click then make a javascript function like below and call it on click of a button.
<script>
function setVal()
{
document.getElementById('NAME_LAST').value = 'ABC' ;
}
</script>
<input type="button" name="b1" onclick=setVal();"/>
for more reading on javascript you can refer to
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.