/    Sign up×
Community /Pin to ProfileBookmark

Dynamic DOM lookup

I’m sure this is possible but I’m having a hard time doing it. I need to be able to find a DOM element in a form via a function. i.e.

[CODE]
function disableInput(control)
{
alert(document.myForm. + control + .length); //this doesn’t work
}
[/CODE]

of course the alert isn’t really what I’m looking to do… I know if I put

[CODE]alert(‘document.myForm.’ + control + ‘.length’);[/CODE]

that would spit out what I’m looking for but I need this to work in the code. I tried wrapping that code into a var but then the ‘type’ is off.

It’s probably something simple I’m missing.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangJul 03.2008 — document.myForm.elements[control].length
×

Success!

Help @CantonDog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...