Forum Moderators: open
I have tried var's and then calling them from a table and that worked, but I want like a link on the page that changes just that spicific content.
bad example:
head
<script type="txt/javascript">
var one = "this message"
var two = "another message"
</script>
body
<table>
<tr><td id="td1">
<script type="txt/javascript">
documents.write(one)
</script>
</td></tr>
</table>
and then maybe a link to change the td1 from var one to var two?
Please oh please help me....
innerHTML is probably the simplest way to put new content on a page. It does have a number of limitations and is not a W3C-approved standard, but it is a well-supported browser convention. Some argue that it is better to use the W3C-sanctioned methods of creating and adding a document node, but it is generally recognized as a more complex technique.
Try this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
body{height:100%;background:#dee;}
</style>
</head>
<body>
<p style="margin:2em;">
<a href="#" onclick="document.write('Whoa, where\'d it go?');return false;">document.write()</a>
</p>
<div style="border:2px solid;padding:2em;margin:.2em;">
<p>
<a href="#" onclick="document.getElementById('pOne').innerHTML='That\'s more like it.';">innerHTML</a>
</p>
<p id="pOne">Text to be replaced by innerHTML, in paragraph with id="pOne"
</p>
</div>
</body>
</html>