Phényx
01-13-2003, 11:02 PM
Hi !
I've created a labelled <div> section, and want to know if there is a javascript command to write something in the <div> section (like the document.write(string) command does to the wole document)
thx ;-)
chrismiceli
01-13-2003, 11:19 PM
give the div an id
<div id="divid"></div>
<script type="text/javascript">
document.getElementById("divid").innerHTML = "hi";
</script>
you could also put html in the div just like you could w/ document.write();
Phényx
01-15-2003, 12:04 PM
Thanks !
Your code is great but try this one :
It works both on IE and Mozilla :thumbsup:
<script>
function WriteDiv(text, id) {
if (document.getElementById) {
x = document.getElementById(id);
x.innerHTML = '';
x.innerHTML = text;
}
else if (document.all) {
x = document.all[id];
x.innerHTML = text;
}
}
</script>
Borgtex
01-15-2003, 12:30 PM
Simplified, assuming that it's IE or Mozilla:
<script>
function WriteDiv(text, id)
{
x = document.all?document.all[id]:document.getElementById(id);
x.innerHTML = text;
}
</script>