ck my checkbox input

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

    #1

    ck my checkbox input

    I am dynamically creating an input that is a checkbox like:

    myINPUT = document.create Element("INPUT" );
    myINPUT.type = "checkbox";
    myINPUT.id = myINPUT.name = "myck_box";
    myINPUT.value = "Y";
    myINPUT.checked = true;
    myINPUT.disable d = true;

  • mike

    #2
    Re: ck my checkbox input

    I forgot to mention that it is not getting checked ....

    Comment

    • mscir

      #3
      Re: ck my checkbox input

      mike wrote:[color=blue]
      > I forgot to mention that it is not getting checked ....[/color]

      This works on my IE 6, Netscape 7.2, Firefox 1.0.3, Mozilla 1.7.3 :

      var myDiv = document.getEle mentById('somed iv');
      var myINPUT = document.create Element("INPUT" );
      myINPUT.type = "checkbox";
      myINPUT.id = "myck_box";
      myINPUT.name = "myck_box";
      myINPUT.value = "Y";
      myINPUT.disable d = true;
      myDiv.appendChi ld(myINPUT);
      myINPUT.checked = true;

      Comment

      • mike

        #4
        Re: ck my checkbox input

        I see .... I have to check it after I create it, i.e. I can't create it
        in the "checked" condition.

        Thanks, let me try that

        Comment

        • Fred Oz

          #5
          Re: ck my checkbox input

          mike wrote:[color=blue]
          > I see .... I have to check it after I create it, i.e. I can't create it
          > in the "checked" condition.[/color]

          No, for IE you have to check it after you *add it to the document*,
          Firefox is quite happy for you to check it anytime after it is
          created.

          Until the checkbox is added to the document (either by appending it
          to an element that is part of the document, or adding its parent
          element to the document), IE will not check it.

          In either case you must create it first before you can do anything
          with it - I suspect that will be true of all browsers.
          [color=blue]
          >
          > Thanks, let me try that
          >[/color]

          Ok.

          --
          Fred

          Comment

          • Dietmar Meier

            #6
            Re: ck my checkbox input

            mike wrote:
            [color=blue]
            > I see .... I have to check it after I create it, i.e. I can't create
            > it in the "checked" condition.[/color]

            You can. When the checkbox is added to the document (or when the
            document is (re)loaded or the form reset), its "defaultChecked "
            property determines its initial checked status.

            myINPUT = document.create Element("INPUT" );
            myINPUT.type = "checkbox";
            myINPUT.id = myINPUT.name = "myck_box";
            myINPUT.value = "Y";
            myINPUT.default Checked = true;
            myINPUT.disable d = true;

            ciao, dhgm

            Comment

            Working...