HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 24th, 2000, 04:57 PM
shelly shelly is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2000
Posts: 1 shelly User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

I am trying to dynamically change the cell of a table. This works fine in IE. I have an "ID=" on the <td> tag and can use the innerhtml property to change the contents of the cell. In netscape, I tried to use the document.layers['id1'].document.write(), but it doesn't seem to recognize the "id" on the <td> tag. So I tried using the <div> tag which essentially creates another layer. So on the first layer I have an empty cell and on the second layer I have just the <td> and I position it using the top: and left: properties. But this causes problems when resizing.

Is there an easier way to do this?
Any suggestions would be appreciated.

Shelly

Reply With Quote
  #2  
Old March 26th, 2000, 04:54 AM
firepages's Avatar
firepages firepages is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: Perth West Australia
Posts: 741 firepages User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
<a href="javascript:WriteIt('DIVid',null,'yourtext')"></a>

<script>
function WriteIt(id,nestref,text) {
if (ns4) {
var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document
lyr.open()
lyr.write(text)
lyr.close()
}
else if (ie4) document.all[id].innerHTML = text
}
</script>

the null - should be used if you have a nested layer - alternatly try a <span id="id>text</span>


------------------
Simon Wheeler
FirePages -DHTML/PHP/MySQL

Reply With Quote
  #3  
Old April 1st, 2000, 05:49 AM
KliK KliK is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Location: Rumilly, HS, France
Posts: 8 KliK User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
There is a bug in NS when you resize the window. To avoid this problem you have to write this script :

window.onresize = location.reload;

This will reload the page after resizing the window.

Reply With Quote
  #4  
Old May 23rd, 2000, 11:04 AM
sacrilegious sacrilegious is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2000
Posts: 16 sacrilegious User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
use data binding

i've replied to a similar question elsewhere - check that one out:
http://www.devshed.com/Talk/Forums/...TML/000241.html

Ajmal.

Reply With Quote
  #5  
Old August 9th, 2000, 03:17 PM
jonathanhahn jonathanhahn is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2000
Location: Santa Clara, CA, USA
Posts: 3 jonathanhahn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Simon,

I tried your javascript and the text doesn't appear on the document. I tried to change the original text and it disappeared. Is there something else i need to do?

Thanks in advance,
jon

<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by firepages:
<a href="javascript:WriteIt('DIVid',null,'yourtext')"></a>

<script>
function WriteIt(id,nestref,text) {
if (ns4) {
var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document
lyr.open()
lyr.write(text)
lyr.close()
}
else if (ie4) document.all[id].innerHTML = text
}
</script>

the null - should be used if you have a nested layer - alternatly try a <span id="id>text</span>


[/quote]


Reply With Quote
  #6  
Old August 11th, 2000, 01:11 AM
firepages's Avatar
firepages firepages is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: Perth West Australia
Posts: 741 firepages User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Hi johnathon, oooops my coding was a bit sloppy wasnt it!, anyway here is a working example, I just tested it to be safe, you do not need to use netscapes <layers> and you should try to avoid them anyway - slap on the wrist for me as I have used if(document.layers) in the script below.

anyway it should give you something to work from.

<html>
<head>
<script>
function WriteIt(id,nestref,text) {
if (document.layers) {
var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document
lyr.open()
lyr.write(text)
lyr.close()
}
else if(document.all) {document.all[id].innerHTML = text
alert("here");}
}
</script>
</head>
<body bgcolor="#ffffff">
<div id="thisdiv" style="position:absolute;top:0;left:0;">hello world</div>
<a href="javascript:WriteIt('thisdiv',null,'look it actually works.')">testit</a>
</body>
</html>

it is a good idea also to put the text in a table within the div if you want to keep any formatting (for netscape).

If the div was nested ie <div id=bella><span id=rosa>text etc</span></div> then you would use <a href="javascript:WriteIt('bella','rosa','look it still works.')">testit</a>.

sorry for the confusion


------------------
Simon Wheeler
FirePages -DHTML/PHP/MySQL

Reply With Quote
  #7  
Old October 16th, 2000, 09:19 AM
rinadib rinadib is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 8 rinadib User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
hello,

Does anyone know how to make this work in
a table cell. I used the same thing as above but put the <div> in a table cell, and used relative positioning intead of absolute.
When you click 'testit' the new text is not in the table cell !!
I tried it with <SPAN> as well and I get the same thing!
Any help would be greatly appreciated.
Thanks.

<html>
<head>
<script>
function WriteIt(id,nestref,text) {
if (document.layers) {
var lyr = (nestref)? eval('document.'+nestref+'.document.'+id+'.document') : document.layers[id].document
lyr.open()
lyr.write(text)
lyr.close()
}
else if(document.all) {document.all[id].innerHTML = text
alert("here");}
}
</script>
</head>
<body bgcolor="#ffffff">
<TABLE BORDER=1>
<TR><TD>
<div id="thisdiv" style="position:relative;">hello world</div>
</TD></TR>
</TABLE>
<a href="javascript:WriteIt('thisdiv',null,'look it actually works.')">testit</a>
</body>
</html>

Reply With Quote
  #8  
Old October 19th, 2000, 02:26 PM
csturg csturg is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2000
Posts: 1 csturg User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am having exactly the same problem. However, I have noticed that resizing the browser window makes the new table cell contents appear. Maybe there is a function call that would perform the same layer refresh as the browser resize. Any ideas would be appreciated.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > dynamically changing the content of a table cell with Netscape


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway