populating div with stuff from JScript

liunx

Guest
Hi,<br />
<br />
Is it possible to populate a div element with html using JavaScript? Probably not explaining myself properly so here's what I've got (Please don't laugh, I'm a noobie!)<br />
<br />
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br />
<html><br />
<head><br />
<title>Untitled Document</title><br />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><br />
<br />
<script language="JavaScript1.2"><br />
<br />
function dropDown() {<br />
document.myform.mydiv.value="<P>HELLO</P>"<br />
}<br />
<br />
</script><br />
</head><br />
<br />
<body><br />
<form name="myform"><br />
<img src=http://www.htmlforums.com/archive/index.php/"file:///C|/title.gif" onClick="javascript:dropDown()"></img><br />
<div name="mydiv"></div><br />
</form><br />
</body><br />
</html><br />
<br />
It complains with 'document.myform.luke' is not null or not an object. Is what I'm trying to do not possible?<br />
<br />
Thx in advance!<!--content-->Ok, 3 things I see:<br />
1. in the div tag it should be id="mydiv" not name<br />
2. in the javascript, try document.all.innerHTML='<p>HELLO</p>';<br />
3. make sure that you call the function in your HTML *BELOW* the div. Otherwise, the div has not yet been made, and it will give you that error.<!--content-->also I don't see a name called 'luke' either.<!--content-->Sorry about that, I replaced luke with mydiv!<br />
<br />
Thanks for your help, got it going now :rocker:<!--content-->
 
Back
Top