Connecting Tech Pros Worldwide Help | Site Map

newby trying to write text to a <div>

 
LinkBack Thread Tools Search this Thread
  #1  
Old February 9th, 2006, 02:55 PM
charliefortune
Guest
 
Posts: n/a
Default 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.


  #2  
Old February 9th, 2006, 03:05 PM
Evertjan.
Guest
 
Posts: n/a
Default Re: newby trying to write text to a <div>

charliefortune wrote on 09 feb 2006 in comp.lang.javascript:
[color=blue]
> 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">[/color]

Do not use language="JavaScript", unnecessary since abt. 2000
[color=blue]
> function design(file, displayName){
> viewer.src = 'assets/shirts/medium/'+ file +'.gif';
> document.underText.write(displayName);[/color]

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;
[color=blue]
> }
> </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.
>
>[/color]



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
  #3  
Old February 9th, 2006, 09:35 PM
charliefortune
Guest
 
Posts: n/a
Default Re: newby trying to write text to a <div>

spot on, thank you v much.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.