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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modify substring in div NN4

Status
Not open for further replies.

patter

Programmer
Sep 8, 2002
5
FR
hello

I'd like to change only a few letters in a lengthy text, which is inside a div layer.

Needs to work only on Netscape4

Exemple: here's my div

Code:
<div id='x' ><table><tr><td><p>The answer is 42, not counting the fish.</p></td></tr></table></div>

Let's say I want to change 42 to 24.

I do this

Code:
function change_txt()
{
var txt = document.layers['x']
txt.document.open()
txt.document.write('<table><tr><td><p>The answer is 24, not counting the fish.</p></td></tr></table>')
txt.document.close()
}

But since it's a long text, I'd like to avoid re-writing the whole of it (plus the html tags) in the div.

I've tried
Code:
toString()
so the whole of the div content becomes a string, then I would use
Code:
my_string.replace('42','24')

but it doesn't work.

PS: I'd like to keep my 'div-table-paragraph' structure unchanged.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top