How can i create html elements dynamically?

First of all i'm still in the learning process and slowly trying to push myself to the next level in web development so please help me
____________________________________________________________
I'm making a small word document maker, it can make text dynamically and insert images dynamically too. but i cannot use a simple text area because i want to make it dynamically. i cannot insert images with a textbox. So i decided to make an iframe and made another html tag inside of it for the work area and i was planning to make the text and the inserting of images dynamically inside the iframe>html. But I don't have a clue and an idea how to do this. i know its possible creating the text and inserting images there but I don't know how to build them dynamically. I was thinking while typing its inserting html elements like paragraph tags and such.. can anyone help or give me an idea?

Comments

  • You can create dynamic elements using something like below; you may also want to experiment with the various properites, function, etc to get an idea of what can be done.

    HTH

    [code]

    function addEle(eleType, eleID, bindTo, eWidth, eHeight) {

    try {

    if(document.getElementById("some id") == null ||
    document.getElementById("some id") == undefined) {

    var elem = document.createElement(eleType);
    var htag = document.getElementById(bindTo);

    elem.id = eleID;
    elem.style.backgroundColor = "#ffff00";
    elem.style.fontFamily = "arial, verdana, sans-serif";
    elem.style.fontSize = "22px";
    elem.style.width = eWidth + "px";
    elem.style.height = eHeight + "px";
    elem.value = "inside of the text area";
    elem.readOnly = 1;

    htag.appendChild(elem);
    }
    } catch(e) { alert("could not create " + eleType); }
    }


    click me
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion