document.createElement

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • oeyvind toft

    #1

    document.createElement

    How do I create a checkbox element ? Or any other input type ?
    document.create Element('checkb ox') doesnt seem to work.

    Oeyvind
    --





  • Martin Honnen

    #2
    Re: document.create Element



    oeyvind toft wrote:
    [color=blue]
    > How do I create a checkbox element ? Or any other input type ?
    > document.create Element('checkb ox') doesnt seem to work.[/color]

    var checkbox = document.create Element('input' );
    checkbox.type = 'checkbox';
    checkbox.name = 'checkboxName';
    checkbox.defaul tChecked = true/false
    checkbox.value = 'Kibology';


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • oeyvind toft

      #3
      Re: document.create Element

      Of course, why didnt I think of that...


      Thanks Martin !!

      Oeyvind

      --




      "Martin Honnen" <mahotrash@yaho o.de> skrev i melding
      news:4139cdfd$0 $28475$9b4e6d93 @newsread4.arco r-online.net...[color=blue]
      >
      >
      > oeyvind toft wrote:
      >[color=green]
      > > How do I create a checkbox element ? Or any other input type ?
      > > document.create Element('checkb ox') doesnt seem to work.[/color]
      >
      > var checkbox = document.create Element('input' );
      > checkbox.type = 'checkbox';
      > checkbox.name = 'checkboxName';
      > checkbox.defaul tChecked = true/false
      > checkbox.value = 'Kibology';
      >
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/[/color]


      Comment

      • Ivo

        #4
        Re: document.create Element

        > "Martin Honnen" skrev[color=blue][color=green]
        > >
        > > oeyvind toft wrote:
        > >[color=darkred]
        > > > How do I create a checkbox element ? Or any other input type ?
        > > > document.create Element('checkb ox') doesnt seem to work.[/color]
        > >
        > > var checkbox = document.create Element('input' );
        > > checkbox.type = 'checkbox';
        > > checkbox.name = 'checkboxName';
        > > checkbox.defaul tChecked = true/false
        > > checkbox.value = 'Kibology';[/color][/color]

        Some browsers have a problem assiging names to dynamically created input
        elements in this way. You should define the name like so:

        var checkbox = document.create Element('<input name="chName">' );

        --Iv


        Comment

        • Michael Winter

          #5
          Re: document.create Element

          On Sun, 5 Sep 2004 23:32:43 +0200, Ivo <no@thank.you > wrote:

          [Modifying attributes after a createElement call]
          [color=blue]
          > Some browsers have a problem assiging names to dynamically created input
          > elements in this way. You should define the name like so:
          >
          > var checkbox = document.create Element('<input name="chName">' );[/color]

          Whilst Microsoft may support that syntax, it is *not* correct. The
          argument is the element name only.

          I can't test with Mozilla at the moment, but Opera returns undefined[1]
          with such a call, so the approach cannot be recommended at all.

          Mike


          [1] I'm surprised it didn't throw an exception.

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail.

          Comment

          Working...