473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

newby trying to write text to a <div>

I have succesfully made rollover images appear in a table cell, but I
cannot seem to make the caption appear in a seperate cell underneath.
This is how I attempted it ..

<script language="JavaScript" type="text/JavaScript">

function design(file, displayName){
viewer.src = 'assets/shirts/medium/'+ file +'.gif';
document.underText.write(displayName);
}
</script>
........
....
..
<td><div name = "underText" id = "underText"></div></td>
.......
......
The variables are being passed correctly as viewer.src works correctly.
The script appears before the <html> tag, but it doesn't seem to work
wherever I put it.

Feb 9 '06 #1
2 1472
charliefortune wrote on 09 feb 2006 in comp.lang.javascript:
I have succesfully made rollover images appear in a table cell, but I
cannot seem to make the caption appear in a seperate cell underneath.
This is how I attempted it ..

<script language="JavaScript" type="text/JavaScript">
Do not use language="JavaScript", unnecessary since abt. 2000
function design(file, displayName){
viewer.src = 'assets/shirts/medium/'+ file +'.gif';
document.underText.write(displayName);
You cannot use document.underText unless it is IE-only.
You cannot use .write like that anyway.
You cannot even use document.write after the page is ready,
and the DOM made, because an default documnet.open will be assumed and
that will destroy the previous HTML, DOM and the script itself!!!

So use the DOM to write to a div:

document.getElementById('underText').innerHTML = displayName;
}
</script>
.......
...
.
<td><div name = "underText" id = "underText"></div></td>
......
.....
The variables are being passed correctly as viewer.src works correctly.
The script appears before the <html> tag, but it doesn't seem to work
wherever I put it.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 9 '06 #2
spot on, thank you v much.

Feb 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Catherine Lynn Smith | last post by:
I am creating a webpage with dhtml <DIV> layers and I want a link on one layer to modify the content on another but I seem to keep running into errors. Basically I create a layer in the middle...
7
by: F. Da Costa | last post by:
Hi, I' looking to retrieve ProdName1 form the <tr> below. <tr id="1-1-1" class="even"> <td> <div class="tier4"> <a href="#" class="leaf"></a> ProdName1 </div>
55
by: Ton den Hartog | last post by:
Stupid basic question but I find it horribly imposible to find the answer elsewhere... :-( I want to have a piece of text in my HTML page and want to be able to change it in a Javascript...
8
by: Daniel Hansen | last post by:
I know this must seem totally basic and stupid, but I cannot find any reference that describes how to control the spacing between <p>...</p> and <div>...</div> blocks. When I implement these on a...
6
by: Marcus Otmarsen | last post by:
Ok, the situation is as follows: I defined a <DIV> like: <div id="myid" style="position: absolute; height: 10; width: 10;"><img src="images/object.gif" height=10 width=10></div> This pane is...
4
by: David | last post by:
I attempted the following <div id="div" runat="server"> <tr><td></td></tr> <tr><td></td></tr> </div> This is to hide a group of rows depending on some business rules in my code behind.
3
by: Josef K. | last post by:
Asp.net generates the following html when producing RadioButton lists: <td><input id="RadioButtonList_3" type="radio" name="MyRadioButtonList" value="644"...
2
by: billflu | last post by:
I have a two column table. That looks like this. ____________________ | | | |-----| | | | | | | | | | | |____...
6
goatboy
by: goatboy | last post by:
So I am hosting a site from my home server, and I would like the main page to be an area for updates about the site. I am providing these updates in a blog-style format, using this code: ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.