adding elements to the DOM

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default adding elements to the DOM

    Hi all,

    I'm pretty sure this can be done, but I'm not sure. I'm trying to figure out
    how an element can be added to the document on the fly (due to user input),
    using JavaScript. For example, adding an addition input field to a form if
    the user wants one (I'm familiar with setting up the field once it's
    actually there).

    If anyone's curious, it's for a CMS system. Any help would be very much
    appreciated.

    Thanks
    Rob


    rob :: digitalburn Guest

  2. Similar Questions and Discussions

    1. DW9 quits when adding Spry Menu elements
      Using version 9.0 build 3481 on a Mac G5 tower (2@ 2GHz). I inserted a Spry Menu Bar (vertical). Adding the first few items went smoothly, but now...
    2. Adding layout elements within custom control
      Hi all, I have a custom control that I use within forms that contains form inputs and validator controls. At the moment I'm overriding the Render...
    3. Adding Spread Sheet or Tables to Elements?
      I am trying to figure out how to add a spread sheet or columned text to an element document formatted as a brochure
    4. Adding elements/properties to class
      Ok I have written a simple little class (Attached below.) Is there a way to add elements to this class in my main movie file? like instead of test...
    5. Adding a Copyright Layer in Elements 2.0
      I would like to go ahead and pre-save copyright labels such as "Photos by Ken Little © 2003" on different transparent layers in different colors with...
  3. #2

    Default Re: adding elements to the DOM

    Hum, I found an IE specific way to do it easily (insertAdjacentHTML), but
    I'd rather find a DOM compatible technique.

    I did find the DOM way to create an element (createElement), but no way to
    insert it into the document tree.


    rob :: digitalburn Guest

  4. #3

    Default Re: adding elements to the DOM

    rob :: digitalburn wrote:
    > Hi all,
    >
    > I'm pretty sure this can be done, but I'm not sure. I'm trying to figure out
    > how an element can be added to the document on the fly (due to user input),
    > using JavaScript. For example, adding an addition input field to a form if
    > the user wants one (I'm familiar with setting up the field once it's
    > actually there).
    >
    > If anyone's curious, it's for a CMS system. Any help would be very much
    > appreciated.
    you could try to append to the innerHTML of the form tag.

    place in the head of your document:

    <script>
    function addFormField(f){
    f.innerHTML += '<input type="text" name="newTextField" value="type here">';
    }
    </script>

    then put this button on your page:

    <input type="button" value="Add Field" onclick="addFormField(this.form)">


    this will add to the end of your form. Of course you may not want it at
    the end, but in a particular place, if so, then you could add a div
    inside your form and append to it's innerHTML.


    --
    Enjoy,
    Danilo Celic

    | Extending Knowledge, Daily
    | [url]http://www.CommunityMX.com/[/url]

    Those who aren't looking often have their eyes open widest.

    danilocelic Guest

  5. #4

    Default Re: adding elements to the DOM


    Thanks. If I was going to do this, I might as well use the system I outlined
    above though, as it's more robust I think. What I'm really looking for is
    something DOM compatible - as far as I know, the innerHTML property is IE
    only.

    Thanks again.


    "danilocelic" <danilo@shimmerphase.com> wrote in message
    news:bn8s44$kd2$1@forums.macromedia.com...
    > rob :: digitalburn wrote:
    >
    > > Hi all,
    > >
    > > I'm pretty sure this can be done, but I'm not sure. I'm trying to figure
    out
    > > how an element can be added to the document on the fly (due to user
    input),
    > > using JavaScript. For example, adding an addition input field to a form
    if
    > > the user wants one (I'm familiar with setting up the field once it's
    > > actually there).
    > >
    > > If anyone's curious, it's for a CMS system. Any help would be very much
    > > appreciated.
    >
    > you could try to append to the innerHTML of the form tag.
    >
    > place in the head of your document:
    >
    > <script>
    > function addFormField(f){
    > f.innerHTML += '<input type="text" name="newTextField" value="type
    here">';
    > }
    > </script>
    >
    > then put this button on your page:
    >
    > <input type="button" value="Add Field" onclick="addFormField(this.form)">
    >
    >
    > this will add to the end of your form. Of course you may not want it at
    > the end, but in a particular place, if so, then you could add a div
    > inside your form and append to it's innerHTML.
    >
    >
    > --
    > Enjoy,
    > Danilo Celic
    >
    > | Extending Knowledge, Daily
    > | [url]http://www.CommunityMX.com/[/url]
    >
    > Those who aren't looking often have their eyes open widest.
    >

    rob :: digitalburn Guest

  6. #5

    Default Re: adding elements to the DOM

    rob :: digitalburn wrote:
    > Thanks. If I was going to do this, I might as well use the system I outlined
    > above though, as it's more robust I think. What I'm really looking for is
    > something DOM compatible - as far as I know, the innerHTML property is IE
    > only.
    The method I showed works in NN7.1 and IE6. Didn't test in other browsers.

    --
    Enjoy,
    Danilo Celic

    | Extending Knowledge, Daily
    | [url]http://www.CommunityMX.com/[/url]

    Those who aren't looking often have their eyes open widest.

    danilocelic Guest

  7. #6

    Default Re: adding elements to the DOM


    I'm not too fussed about browser compatibility (as only one person will use
    this and he has IE), I've just suddenly got a thing for W3C standards, and
    according to the reference that comes with DW, innerHTML ain't in them :) It
    doesn't really matter though, thanks for your time :)

    > The method I showed works in NN7.1 and IE6. Didn't test in other browsers.
    >
    > --
    > Enjoy,
    > Danilo Celic
    >
    > | Extending Knowledge, Daily
    > | [url]http://www.CommunityMX.com/[/url]
    >
    > Those who aren't looking often have their eyes open widest.
    >

    rob :: digitalburn Guest

  8. #7

    Default Re: adding elements to the DOM

    rob :: digitalburn wrote:
    > I'm not too fussed about browser compatibility (as only one person will use
    > this and he has IE), I've just suddenly got a thing for W3C standards, and
    > according to the reference that comes with DW, innerHTML ain't in them :) It
    > doesn't really matter though, thanks for your time :)
    You're correct, it's not part of the spec, but modern browsers support
    it, and that's enough for me.


    Enjoy,
    Danilo Celic

    | Extending Knowledge, Daily
    | [url]http://www.CommunityMX.com/[/url]

    Those who aren't looking often have their eyes open widest.

    danilocelic Guest

  9. #8

    Default Re: adding elements to the DOM

    I must admit I usually use it too... I was just set on doing things the
    'proper' way this time around :)


    rob :: digitalburn Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139