Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript question

Name: Anonymous 2011-08-19 14:28

How do you add some content in a specific place in Javascript at the user's bequest? I'm writing a sort of CSS designer with the idea that it shows the user what the style looks like by writing it to a file and then loading it (using PHP). The thing is I want it to actually be useful, so it needs to be able to have as many elements and properties as the user wants. I know that trick where you have an empty <div> and set its innerHTML member but that will leave me a set number, and I don't want to just stick billions and billions of <div> tags inside my code (its already messy enough).

tl; dr how do I dynamically instert code into a webpage at a set position but allowing an arbitrary number of insertions?

Name: Anonymous 2011-08-19 19:25

>>21
function add_property()
{
    alert("Add property");
    var div = document.createElement("div");
    div.innerHTML = document.getElementById("ee2e7a91").innerHTML;
    if (document.getElementById("ee2e7a91").innerHTML == null)
        alert("null");
    else
        alert("Not null");
    document.body.appendChild(div);
}

Well, I tried this code, and the second alert says "Not null" so it is returning an element handle. Your code works, though.


I just tried this:
alert(document.getElementById("ee2e7a91").innerHTML);
and it is blank.

That <div> is not blank though:
<div id="ee2e7a91">
    <tr>
        <td></td>
        <td>
            <select>
                <?php
                    /*
                     * Generate list of options
                     */
                    $file = fopen("res/properties.lst", "r");
                    while (!(feof($file))) {
                        $string = rtrim(fgets($file));
                        if ($string != "")
                            echo "<option value=\"$string\">$string</option>\n";
                    }
                    fclose($file);
                ?>
            </select>
        </td>
        <td>:</td>
        <td>
            <input type="text" />;
        </td>
    </tr>
</div>


>>20
Thanks, I'll take a look. I'm using FF6 as of today, btw.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List