Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37200
| Path | csiph.com!aioe.org!.POSTED.wIgm+2MIUUYkuZKIR0Uhug.user.gioia.aioe.org!not-for-mail |
|---|---|
| From | "R.Wieser" <address@not.available> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Create a string dynamically to reference a property of an object? |
| Date | Tue, 10 Sep 2019 21:59:24 +0200 |
| Organization | Aioe.org NNTP Server |
| Lines | 43 |
| Message-ID | <ql8vb5$iqr$1@gioia.aioe.org> (permalink) |
| References | <aba8a905-8515-4be8-9e03-040f60d109e5@googlegroups.com> |
| NNTP-Posting-Host | wIgm+2MIUUYkuZKIR0Uhug.user.gioia.aioe.org |
| X-Complaints-To | abuse@aioe.org |
| X-Priority | 3 |
| X-MimeOLE | Produced By Microsoft MimeOLE V6.00.2900.5512 |
| X-Notice | Filtered by postfilter v. 0.9.2 |
| X-Newsreader | Microsoft Outlook Express 6.00.2900.5512 |
| X-MSMail-Priority | Normal |
| X-RFC2646 | Format=Flowed; Original |
| Xref | csiph.com comp.lang.javascript:37200 |
Show key headers only | View raw
Jonas,
> varString="document.getElementById.('inBox"+x+"').checked";
Remove the "." just infront of the "(" and try again.
Hint: When something doesn't work /go back to the simpelest form you know/ -
in this case trying to execute it directly, and with any additions like
dynamic ID names:
console.log("***"+ document.getElementById.('inBox0').checked );
The above wil fail too, due to that extra ".". But with a bit of luck (and
the right tools, which you already seem to use) you will get a lot more info
about /what/ is going wrong, and can repair it yourself.
And by the way: I hope you do realize that the element id you are using
itself is, after you create that string, not dynamic but hardcoded.
Ackk .. I just remembered something ...
And #&$&*^$ @ !!
Forget that. I just realized that your explanation was inprecise enough to
make me think your "object property references" was referring to the
".checked" part. Looking at your previous (differently named, so a bit of
a gamble) post thats not quite likely. Give yourself a "well done" slap
on the shoulder, you just made me waste my time. :-(
And that also means that if that element id is the /only/ thing thats
dynamic you do not even need to go thru storing it into a variable and than
eval-ing it. It will work perfectly whe you use it directly:
x=1
var myVar = document.getElementById('inBox'"+x+"').checked;
So much for not first trying the simpelest approach first, eh ? <whistle>
:-)
Regards,
Rudy Wieser
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Create a string dynamically to reference a property of an object? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-10 11:41 -0700
Re: Create a string dynamically to reference a property of an object? Julio Di Egidio <julio@diegidio.name> - 2019-09-10 12:38 -0700
Re: Create a string dynamically to reference a property of an object? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-10 14:02 -0700
Re: Create a string dynamically to reference a property of an object? dr.j.r.stockton@gmail.com - 2019-09-11 12:58 -0700
Re: Create a string dynamically to reference a property of an object? "R.Wieser" <address@not.available> - 2019-09-10 21:59 +0200
Re: Create a string dynamically to reference a property of an object? Julio Di Egidio <julio@diegidio.name> - 2019-09-10 13:04 -0700
Re: Create a string dynamically to reference a property of an object? "R.Wieser" <address@not.available> - 2019-09-11 09:33 +0200
Re: Create a string dynamically to reference a property of an object? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-11 00:52 -0700
Re: Create a string dynamically to reference a property of an object? "R.Wieser" <address@not.available> - 2019-09-11 10:11 +0200
Re: Create a string dynamically to reference a property of an object? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-11 02:09 -0700
Re: Create a string dynamically to reference a property of an object? "R.Wieser" <address@not.available> - 2019-09-11 13:59 +0200
Re: Create a string dynamically to reference a property of an object? Julio Di Egidio <julio@diegidio.name> - 2019-09-11 02:11 -0700
Re: Create a string dynamically to reference a property of an object? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-09-11 03:48 -0700
Re: Create a string dynamically to reference a property of an object? "R.Wieser" <address@not.available> - 2019-09-11 13:48 +0200
csiph-web