Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: Is it possi...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 14 Topic 35552 of 37128
Post > Topic >>

Re: Is it possible to create dynamic var

by DL <tatata9999@[EMAIL PROTECTED] > May 10, 2008 at 08:32 PM

On May 10, 10:06=A0pm, DL <tatata9...@[EMAIL PROTECTED]
> wrote:
> On May 10, 6:45=A0pm, VK <schools_r...@[EMAIL PROTECTED]
> wrote:
>
>
>
>
>
> > On May 10, 7:53 am, DL <tatata9...@[EMAIL PROTECTED]
> wrote:
>
> > > For instance,
>
> > > function addNew(i) {
> > > var 'element'&i
> > > ..
>
> > > }
>
> > > If possible, how to?
>
> > Javascript is not a prehistoric BASIC subset for such perversions. If
> > you need uniformly accessible elements of unknown in advance amount
> > then use array:
>
> > var myElements =3D new Array;
>
> > function addNew(i) {
> > =A0myElements[i] =3D whatever;
>
> > }
>
> > If you really need properties named like "foo1', "foo2" etc. then use
> > object's squared brackets notation:
>
> > var myElements =3D new Object;
>
> > function addNew(i) {
> > =A0myElements['foo'+i] =3D whatever;
>
> > }- Hide quoted text -
>
> > - Show quoted text -
>
> Thanks. =A0First let me get simple thing off the list first, your
>
> var myElements =3D new Array;
> is probably similar to
> var myElements =3D []; // the later is a short form probably, yes?
>
> Now, back to the main topic. =A0Also, I should have been clearer about
> the intent of the code, that is, to dynamically add TR or (TRs) for an
> existing table with ID of 'tbl'.
>
> Neither Array nor Object works for this case while
> by doing so by hand, e.g.
> var newF =3D do***ent.getElementById('tbl');
> var tr1 =3D newF.insertRow();
>
> would work. But
>
> var newF =3D do***ent.getElementById('tbl');
> var myElements =3D new Array;
>
> =A0function addNew(i) {
> =A0myElements[i] =3D newF.insertRow();
>
> won't work.
>
> It seems to be me pretty odd that javascript can't handle 'dynamic
> variable assignment'
>
> Thanks.- Hide quoted text -
>
> - Show quoted text -

Ok, you guys are right, I don't even need dynamic vars.  Now got a
minor question,
the following attempt of setting a newly created cell alignment to
right won't work,
e.g. newCell1.style.align =3D "right";
what's wrong?

Thanks.
 




 14 Posts in Topic:
Is it possible to create dynamic var
DL <tatata9999@[EMAIL   2008-05-09 20:53:12 
Re: Is it possible to create dynamic var
Laser Lips <loudsphier  2008-05-10 07:31:42 
Re: Is it possible to create dynamic var
Thomas 'PointedEars' Lahn  2008-05-10 16:34:48 
Re: Is it possible to create dynamic var
Laser Lips <loudsphier  2008-05-10 07:41:48 
Re: Is it possible to create dynamic var
DL <tatata9999@[EMAIL   2008-05-10 15:00:08 
Re: Is it possible to create dynamic var
Thomas 'PointedEars' Lahn  2008-05-11 11:00:56 
Re: Is it possible to create dynamic var
VK <schools_ring@[EMAI  2008-05-10 15:45:03 
Re: Is it possible to create dynamic var
Dr J R Stockton <jrs@[  2008-05-10 22:28:45 
Re: Is it possible to create dynamic var
DL <tatata9999@[EMAIL   2008-05-10 19:06:13 
Re: Is it possible to create dynamic var
DL <tatata9999@[EMAIL   2008-05-10 20:32:57 
Re: Is it possible to create dynamic var
Andrew Poulos <ap_prog  2008-05-11 13:51:11 
Re: Is it possible to create dynamic var
VK <schools_ring@[EMAI  2008-05-11 00:36:02 
Re: Is it possible to create dynamic var
Thomas 'PointedEars' Lahn  2008-05-11 11:11:06 
Re: Is it possible to create dynamic var
DL <tatata9999@[EMAIL   2008-05-11 07:37:43 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 15:00:13 CDT 2008.