javascript class

Results 1 to 7 of 7

Thread: javascript class

  1. #1
    Join Date
    Dec 1969
    Posts
    172

    Default javascript class

    I have this little code about javascript creating classes.Youcan see the problem below,can ASP somehow solve it?<BR><BR>&#060;script&#062;<BR>var dd="";<BR><BR>function myobject() {<BR> this.con = 0;<BR> this.other = 0;<BR> this.another = 0;<BR>}<BR><BR><BR>var mything1 = new myobject();<BR>var mything2 = new myobject();<BR>var mything3 = new myobject();<BR><BR><BR>for (i = 1; i &#060;= 3; i++)<BR>{<BR>dd="mything" + i;<BR>alert(dd);<BR>dd.con=i*2;<BR>dd.other=i*2+1; <BR>dd.another=i*2+2;<BR>alert(dd.con); //this output is undefined<BR>}<BR><BR>alert(mything3.con);<BR><BR> &#060;/script&#062;

  2. #2
    Join Date
    Dec 1969
    Posts
    96,118

    Default Ever heard of *ARRAYS*?

    var MyThings = new Array( );<BR><BR><BR>for (i = 1; i &#060;= 3; i++)<BR>{<BR> dd = new myobject();<BR> alert(dd); // this makes no sense...you can&#039;t alert() an *object*!<BR> dd.con=i*2;<BR> dd.other=i*2+1;<BR> dd.another=i*2+2;<BR> alert(dd.con); // okay, makes sense<BR> MyThings(i) = dd; // assign to the array element<BR>}<BR><BR>alert(MyThings(3).con);<BR><BR >

  3. #3
    Join Date
    Dec 1969
    Posts
    6,476

    Default That was fast??

    They whisk you down an assembly line of machetties to slice you open or what?<BR><BR>How ya feeling?

  4. #4
    Join Date
    Dec 1969
    Posts
    172

    Default you are not asleep!!!

    Thanks man!!!<BR>Why could I not think of that???<BR>cenk<BR>


  5. #5
    Join Date
    Dec 1969
    Posts
    96,118

    Default With Vicodin...

    ...I&#039;m not feeling much pain. But I won&#039;t be here long.<BR><BR>Still tire easily and still hurts to get up & down.<BR><BR>Yeah, we got to hospital at 6 AM, I saw the clock say 6:50 before I went under as they were wheeling me down the hallway. We were out of the hospital by 10 AM. No joke. <BR><BR>Probably gone in a few minutes.<BR><BR>

  6. #6
    Join Date
    Dec 1969
    Posts
    96,118

    Default Don't bet on that!

    I know I was writing SQL Server code in my dreams the other night.<BR><BR>

  7. #7
    Join Date
    Dec 1969
    Posts
    6,476

    Default RE: With Vicodin...

    Good to hear it went well.<BR>Amazing how fast they can ship you out after something like that...<BR>20 years ago you would have been in there for 2 or 3 weeks at least...<BR><BR>Take it easy and rest lots.<BR><BR>Nite Bill.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •