cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript Example isn´t working

Former Member
0 Kudos

Hello

I´m trying to set the value of an inputField via Javascript. I found the following example in the pdk documentation:

Getting the inputField object in JavaScript:

function calculateCurrencyFromTo(){

var funcName = htmlb_formid+"_getHtmlbElementId";

func = window[funcName];

var inputfield = eval(func("currencyDisplay"));

// Now we have the inputField, so we can access it, for example set a new value

if (inputfield)

inputfield.setValue("100.23");

}

The only thing, that i´ve changed is the field id according to my field id.

I don´t have any clue why it isn´t working.

Do you have any ideas, or other solutions to fill an input field via javasrcipt

regards

Alexander

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

I use this:

function getHtmlbElement( pElementId )

{

var loDocForms = document.forms;

for( var i=0; i<loDocForms.length; i++ )

{

try

{

var funcName = loDocForms<i>.id + "_getHtmlbElementId";

func = window[funcName];

var element = eval( func(pElementId) );

if(element)

{

return element;

}

}

catch( ex )

{

}

}

}

Cause it could be that there are multiple forms on the current page. The parameter 'elementId' is the id defined on the server.

Regards,

Stefan

Former Member
0 Kudos

thank you very much

you were right about the multiple forms problem.

i had to change the "var funcName..." line to

var funcName=loDocForms [ i ] .id+"_getHtmlbElementId";

it seems that the forum software will ingnore statements like [ i ] if they are written without spaces.

regards alexander

Former Member
0 Kudos

I use this:

function getHtmlbElement( pElementId )

{

var loDocForms = document.forms;

for( var i=0; i<loDocForms.length; i++ )

{

try

{

var funcName = loDocForms<i>.id + "_getHtmlbElementId";

func = window[funcName];

var element = eval( func(pElementId) );

if(element)

{

return element;

}

}

catch( ex )

{

}

}

}

Cause it could be that there are multiple forms on the current page. The parameter 'elementId' is the id defined on the server.

Regards,

Stefan