By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,130 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

pass by reference?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.