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

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

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


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

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";

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

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum