469,323 Members | 1,631 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

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.options[document.myform.myselobj.options.selectedIndex].value
= 2;

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

setFunction(document.myform.myselobj, 2) -> set value of selectedIndex to 2

getFunction(document.myform.myselobj) -> would return current index.

I can do the getFunction:

function getSelectListValue(object)
{
return object.options[object.selectedIndex].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
Jul 23 '05 #1
1 2428
oops. never mind, i think i dont need a f-n for the set case,
since I can simply do

document.myform.myselobj.selectIndex = 2;

sorry for the spam...

-d

On 5/19/2004 5:52 PM, Denis Perelyubskiy:
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.options[document.myform.myselobj.options.selectedIndex].value
= 2;

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

setFunction(document.myform.myselobj, 2) -> set value of selectedIndex to 2

getFunction(document.myform.myselobj) -> would return current index.

I can do the getFunction:

function getSelectListValue(object)
{
return object.options[object.selectedIndex].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

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by z_learning_tester | last post: by
5 posts views Thread by David++ | last post: by
4 posts views Thread by Jon Slaughter | last post: by
14 posts views Thread by Abhi | last post: by
10 posts views Thread by Robert Dailey | last post: by
6 posts views Thread by lisp9000 | last post: by
15 posts views Thread by ramif | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.