problem: create element in create element

Discussion in 'Javascript' started by Iulian Ilea, Dec 14, 2006.

  1. Iulian Ilea

    Iulian Ilea Guest

    Hello,

    I have a problem and I don't understand why this is happening.
    Code:
    calendar = document.createElement("div");
    calendar.setAttribute("id", "calendar");
    table = calendar.createElement("table");
    After I create table element nothing apears on the screen.

    Thanks in advance!
     
    Iulian Ilea, Dec 14, 2006
    #1
    1. Advertising

  2. Iulian Ilea

    Iulian Ilea Guest

    Iulian Ilea wrote:
    > Hello,
    >
    > I have a problem and I don't understand why this is happening.
    > Code:
    > calendar = document.createElement("div");
    > calendar.setAttribute("id", "calendar");
    > table = calendar.createElement("table");
    > After I create table element nothing apears on the screen.
    >
    > Thanks in advance!


    Oh... I found :)

    calendar = document.createElement("div");
    calendar.setAttribute("id", "calendar");

    table = document.createElement("table");
    calendar.appendChild(table);
     
    Iulian Ilea, Dec 14, 2006
    #2
    1. Advertising

  3. Iulian Ilea

    ASM Guest

    Iulian Ilea a écrit :
    > Hello,
    >
    > I have a problem and I don't understand why this is happening.
    > Code:
    > calendar = document.createElement("div");
    > calendar.setAttribute("id", "calendar");
    > table = calendar.createElement("table");
    > After I create table element nothing apears on the screen.
    >
    > Thanks in advance!
    >


    With IE you have to create a tbody before to create tr and tds

    of course you appendChild each new element in right place
    still to the document.body


    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
     
    ASM, Dec 14, 2006
    #3
  4. Iulian Ilea

    ASM Guest

    Iulian Ilea a écrit :
    > Oh... I found :)
    >
    > calendar = document.createElement("div");
    > calendar.setAttribute("id", "calendar");
    >
    > table = document.createElement("table");
    > calendar.appendChild(table);
    >


    what is that ?

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
     
    ASM, Dec 14, 2006
    #4
  5. Iulian Ilea

    Iulian Ilea Guest

    ASM wrote:
    > Iulian Ilea a écrit :
    > > Oh... I found :)
    > >
    > > calendar = document.createElement("div");
    > > calendar.setAttribute("id", "calendar");
    > >
    > > table = document.createElement("table");
    > > calendar.appendChild(table);
    > >

    >
    > what is that ?
    >
    > --
    > Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    > Stephane Moriaux and his (less) old Mac already out of date


    That is the correct way to append an element to a document (from what I
    read). If you look in the first post I appended table to calendar.
     
    Iulian Ilea, Dec 17, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MSNews
    Replies:
    1
    Views:
    2,788
    Alvin Bruney [MVP]
    Apr 22, 2004
  2. Rod  Snyder

    moving from form element to form element

    Rod Snyder, May 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    418
    Vidar Petursson
    May 29, 2004
  3. =?Utf-8?B?Um9iZXJ0?=
    Replies:
    3
    Views:
    6,942
    Steven Cheng[MSFT]
    Nov 15, 2005
  4. Tinker
    Replies:
    4
    Views:
    5,434
    Harry Bosch
    Oct 9, 2005
  5. HANM
    Replies:
    2
    Views:
    762
    Joseph Kesselman
    Jan 29, 2008
Loading...

Share This Page