Forum Moderators: open

Message Too Old, No Replies

text replacement help please

text replacement in web page

         

megamog

7:10 pm on Mar 4, 2005 (gmt 0)

10+ Year Member



I have been tring to change the text inside my web page and I just can't seem to get it write.

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....

kaled

12:28 am on Mar 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've never used it but I think you need to look at the innerHTML property.

Kaled.

Rambo Tribble

2:40 am on Mar 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The document.write() method, when called on an already rendered page, will clear the page and begin an new document.

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>

megamog

1:11 pm on Mar 5, 2005 (gmt 0)

10+ Year Member



That is exactly what I needed You guys rock.
I have been able to mnipulate this to do all the stuff I wanted.

I have one more question but that's a new subject and I will post it in a min.

Thank's again!