New To JavaScript

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JHeavey

    New To JavaScript

    Hello, I found some script which allows me to
    emulate "type down" functionality on a dropdown box in a vb.Net program.
    When I load it into my project I get a message box pop up
    which the script is loaded which says "Expected ")". It
    looks well formed to me. Here is the function

    function divert_entry()
    {
    obj = window.event.sr cElement;
    //debugger;
    if (obj.getAttribu te("persistValu e") == null)
    obj.setAttribut e("persistValue ","");
    var iKey;
    var eAny_Event = window.event;

    iKey = eAny_Event.keyC ode;

    var sChr = String.fromChar Code(iKey);
    if (iKey == 13)
    {
    obj.setAttribut e("persistValue ","");
    return true;
    }

    if (iKey == 8)
    {
    sDelete_Chr = obj.getAttribut e("persistValue ");
    obj.setAttribut e("persistValue ",
    sDelete_Chr.sub string(0,sDelet e_Chr.length - 1));
    sChr = '';
    }
    obj.setAttribut e
    ("persistValue" ,obj.getAttribu te("persistValu e") + sChr);
    lookupItem(obj) ;
    if (((iKey > 33 && iKey < 255) || (iKey
    == 8)) && (iKey ! = 40) && (iKey != 38))
    eAny_Event.retu rnValue = false;
    }

    What actually highlights in the error is the call to the
    function which is loaded as follows:

    drpNumbers.Attr ibutes.Add("onk eydown", "return divert_entry()" )

    It highlights the "return divert_entry()"

    Any ideas why?
    ..
  • Janwillem Borleffs

    #2
    Re: New To JavaScript


    "JHeavey" <jimheavey@hotm ail.com> schreef in bericht
    news:b7df5c8b.0 311141709.3cd5b 2c2@posting.goo gle.com...[color=blue]
    >
    > What actually highlights in the error is the call to the
    > function which is loaded as follows:
    >
    > drpNumbers.Attr ibutes.Add("onk eydown", "return divert_entry()" )
    >
    > It highlights the "return divert_entry()"
    >
    > Any ideas why?
    >[/color]

    Try passing it a function instead of a string, e.g.:

    drpNumbers.Attr ibutes.Add("onk eydown", function () { return
    divert_entry() } );


    JW



    Comment

    Working...