pass by reference?

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

    #1

    pass by reference?

    Hello,

    I think what I am trying to do amounts to pass by reference. Perhaps
    there is other way to do this...

    I need to manipulate indices of selected items in select list. So,
    normally one would write something like


    document.myform .myselobj.optio ns[document.myform .myselobj.optio ns.selectedInde x].value
    = 2;

    Instead, I'd like to write a little set/get functions to save some typing:

    setFunction(doc ument.myform.my selobj, 2) -> set value of selectedIndex to 2

    getFunction(doc ument.myform.my selobj) -> would return current index.

    I can do the getFunction:

    function getSelectListVa lue(object)
    {
    return object.options[object.selected Index].value;
    }

    My question is how to implement the setFunction()

    Sorry if this has been asked before - I googled but did not come up with
    anything useful.

    thanks,

    denis
  • Denis Perelyubskiy

    #2
    Re: pass by reference?

    oops. never mind, i think i dont need a f-n for the set case,
    since I can simply do

    document.myform .myselobj.selec tIndex = 2;

    sorry for the spam...

    -d

    On 5/19/2004 5:52 PM, Denis Perelyubskiy:
    [color=blue]
    > Hello,
    >
    > I think what I am trying to do amounts to pass by reference. Perhaps
    > there is other way to do this...
    >
    > I need to manipulate indices of selected items in select list. So,
    > normally one would write something like
    >
    >
    > document.myform .myselobj.optio ns[document.myform .myselobj.optio ns.selectedInde x].value
    > = 2;
    >
    > Instead, I'd like to write a little set/get functions to save some typing:
    >
    > setFunction(doc ument.myform.my selobj, 2) -> set value of selectedIndex to 2
    >
    > getFunction(doc ument.myform.my selobj) -> would return current index.
    >
    > I can do the getFunction:
    >
    > function getSelectListVa lue(object)
    > {
    > return object.options[object.selected Index].value;
    > }
    >
    > My question is how to implement the setFunction()
    >
    > Sorry if this has been asked before - I googled but did not come up with
    > anything useful.
    >
    > thanks,
    >
    > denis[/color]

    Comment

    Working...