|
Can't address new content
Hi all.
I have an ajax function that goes to the server and retrieves a form, which it then places inside a <div>'s innerHTML, "edit" in this case. The form renders on the screen, but then my script tries to set a few field values and fails.
Here's what I've got:
ajax.get("/templates/editor.html", 1, true, "edit");
This function works and the content of editor.html is displayed on the screen:
<div id="edit_frame">
<div id="edit_toolbar">
<span>X</span>
</div>
<div id="edit_panel">
<form name="main">
<textarea rows=25 cols=50 name="edit_content" id="edit_content">
This is where the content will be edited...
</textarea>
</form>
</div>
</div>
<script>
up();
</script>
The up() function is defined in the original page and also gets called.
function up () {
alert(ajax.req.responseText);
alert(document.getElementById("edit_content"));
document.getElementById("edit_content").value = document.getElementById(edit.source).innerHTML;
}
The first alert() displays the form's source, as expected. The second alert() displays "null," then the rest of the script seems to continue one.
So, how do I get "edit_content" to become part of the DOM so I can manipulate it?
TIA,
Mike.
|