 |
 |
javascript innerHTML
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status:
Offline
|
|
I am trying to use javascript to change a bit of HTML between a set of span tags. My javascript code looks like this:
Code:
document.getElementById(currentItemSpan).innerHTML =
'[tr][td]' + currentItemWhole + currentItemFractions +
currentItemIngredient + currentItemForm;
When I remove the '[tr][td]' part of the previous line, things work fine. I've been able to add HTML tags such as [a href], [img], etc, but for some reason the table tags cause problems. Is there something that I am doing wrong or can this not be done using [tr][td] tags?
(Last edited by milf; Feb 12, 2003 at 07:41 AM.
)
|
|
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status:
Offline
|
|
|
|
|
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Dec 2002
Status:
Offline
|
|
It seems to me it should work with [tr] [td] if you got it to work with other tags. Do you have an opening table tag before it and closing td & tr tags after it? What browser(s) have you tested? Sorry, I have to go to class or I'd work through this one.
edit// could you edit that code sample so that it fits in a smaller window? thx
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Status:
Offline
|
|
Originally posted by milf:
I am trying to use javascript to change a bit of HTML between a set of span tags. My javascript code looks like this:
Code:
document.getElementById(currentItemSpan).innerHTML =
'[tr][td]' + currentItemWhole + currentItemFractions +
currentItemIngredient + currentItemForm;
When I remove the '[tr][td]' part of the previous line, things work fine. I've been able to add HTML tags such as [a href], [img], etc, but for some reason the table tags cause problems. Is there something that I am doing wrong or can this not be done using [tr][td] tags?
Why don't you just leave the td and tr in the html and just set the .innertext instead? I also notice that it appears you're concatenating a string along with the addition of numbers. Javascript might be thinking that instead of addition, you want concatenation. It appears you want some addition and then concatenate the string to the numbers.ToString(). Dunno.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |