cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Hidden field & javascript variable

Former Member
0 Likes
963

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

View Entire Topic
Former Member
0 Likes

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.