Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I dynamically change text inside a <p> tag

Status
Not open for further replies.

NeckBone

Programmer
Oct 15, 2003
47
US
Howdy Folks,

I have a page where I click on a thumbnail to swap images in a <td>. This works fine.

In addition, I want to add a caption underneath the displayed image that will change according to the selected pic.

Is there a cross-browser compatible way to do this? I got it to work in IE but I can't get it to work Nescape 4.

Thanks,
neckbone
 
in netscape 4.x browsers, DOM does not work, there is a round about way try it:

Code:
<html>
<head>
<script>
function validate()
{
	str=document.Frm.t1.value
	if(str.length==0)
	{
		WriteIt("Please enter some text.")
		return;
	}
	if(!str.match(/^[a-z_\- ]+$/i))
	{
		str1=str.replace(/[a-z_\- ]/gi,"")
		WriteIt("These special characters have been included in ur string - "+str1+".")
	}
	else
	{
		WriteIt("Correct!!!")
	}
}
function WriteIt()
{
	if(navigator.appName=="Netscape")
	{
		document.layers[0].document.open()
		document.layers[0].document.write(WriteIt.arguments)
		document.layers[0].document.close()
	}
	else
	{
		document.getElementById("Layer1").innerText=WriteIt.arguments[0]
	}
}
</script>
</head>
<body onload="document.Frm.t1.focus();">
<form name="Frm" action="">
<input type="text" name="t1" value="" onblur="validate()">
<div id="Layer1" style="position:absolute;left:146px;top:179px;">asd</div>
</form>
</body>
</html>

see if this code works...

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top