Forums

This topic is locked

Help passing a variable

Posted 10 Jul 2003 20:10:37
1
has voted
10 Jul 2003 20:10:37 Phil Grimpo posted:
I have a question here...
if the script is calling: document.categoryform.categorymenu.options[index].value and "categoryform" and "categorymenu" are the names of the actual form and select menu, how do I replace those with variables passed to the function?

For Instance:

function MyFunction(Formname, MenuName)

So I can do something like:
document.<Formname>.<MenuName>.options[index].value

What is my syntax for this (if it can be done.

Thanks!

-Grimps


Phil Grimpo
Executive Director
Inspirmedia

Edited by - pgrimpo on 10 Jul 2003 20:11:36

Replies

Replied 10 Jul 2003 22:38:51
10 Jul 2003 22:38:51 Marja Ribbers-de Vroed replied:
Try something like:
<pre id=code><font face=courier size=2 id=code>
function MyFunction(Formname, MenuName,MenuIndex) {
return eval("document." + Formname + "." + MenuName + ".options[" + MenuIndex+ "].value";
}
</font id=code></pre id=code>

--
Marja Ribbers-de Vroed
www.flevooware.nl
www.flevooware.nl/dreamweaver/


Edited by - MarjaR on 10 Jul 2003 22:39:59

Edited by - MarjaR on 10 Jul 2003 22:40:46
Replied 10 Jul 2003 23:15:02
10 Jul 2003 23:15:02 Phil Grimpo replied:
Thank you so much! I got that part working now.

Can I do the same thing here:

it currently is (with absolute references):
with(moduleform1.categoryform1){ do stuff }

Can I do something like that EVAL so I can have moduleform1 and categoryform1 be variables?

Thanks!

-Grimps

Phil Grimpo
Executive Director
Inspirmedia
Replied 10 Jul 2003 23:20:55
10 Jul 2003 23:20:55 Phil Grimpo replied:
nevermind, I got it!! <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle> Thanks again.

Phil Grimpo
Executive Director
Inspirmedia

Reply to this topic