...

View Full Version : replace empty <div> with text after clicking a link



joliett89
10-10-2011, 12:39 PM
How to get this to work?



<html>
<body>
<script type="text/javascript" src="01.js">
<h1>Welcome</h1>
<a href="#" onclick="write(); return false;">Click here</a>
<div id="info_here">
</div>
</body>
</html>

01.js


function write() {
var a=document.getElementById("info_here");
a.innerHTML=document.write("Hello <br />" + "Thanks for clicking");
}

Kor
10-10-2011, 12:43 PM
write is a reserved JavaScript word. And write() is not a dynamic method. innerHTML is enough.



<a href="#" onclick="doWrite(); return false;">Click for info</a>



function doWrite() {
var a=document.getElementById("info_here");
a.innerHTML="Hello<br />Thanks for clicking";
}

joliett89
10-10-2011, 12:52 PM
This is working, thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum