Skip to Content
author's profile photo Former Member
Former Member

Javascript Example isn´t working

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

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 12, 2004 at 02:05 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 12, 2004 at 02:06 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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