Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > javascript innerHTML

javascript innerHTML
Thread Tools
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status: Offline
Reply With Quote
Feb 10, 2003, 05:14 PM
 
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! :)
     
milf  (op)
Mac Enthusiast
Join Date: Nov 2001
Location: Washington, DC 20009
Status: Offline
Reply With Quote
Feb 11, 2003, 08:10 AM
 
Anyone?
Just my $.02 :-)
Ti Powerbook 1Ghz w/ Superdrive ......and lovin' it! :)
     
Senior User
Join Date: Dec 2002
Status: Offline
Reply With Quote
Feb 11, 2003, 10:28 AM
 
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
Reply With Quote
Mar 8, 2003, 12:33 AM
 
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.
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:47 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2