javascript not working
Posted: Sat Sep 25, 2010 6:01 pm
This is my code, and it does not create any element. Anybody please tell me why.
I've tried figuring out for a week or so.
I've tried figuring out for a week or so.
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script language="javascript">
var logout=document.createElement('input');
logout.setAttribute('type', 'button');
logout.setAttribute('value', 'Log out');
logout.setAttribute('onclick', 'window.location="URL"');
document.getElementsByTagName('body')[0].appendChild(logout);
var bb=document.createElement('div');
bb.setAttribute('id','bdiv');
bb.appendChild(spn);
bb.appendChild(logout);
document.getElementsByTagName('body')[0].appendChild(bb);
var inpu=document.createElement('input');
inpu.setAttribute('type','text');
inpu.setAttribute('name','message');
inpu.className='inputbox';
var sendbu=document.createElement('input');
sendbu.setAttribute('type','submit');
sendbu.setAttribute('value','Send');
sendbu.onclick=sendMsg();
var msgfo=document.createElement('form');
msgfo.appendChild(inpu);
msgfo.appendChild(sendbu);
var sb=document.createElement('div');
sb.setAttribute('id','sdiv');
sb.appendChild(msgfo);
document.getElementsByTagName('body')[0].appendChild(sb);
</script>
</body>
</html>