Layout: using javascript innerText problems

started by Jargule on Feb 7, 2005 — RSS Feed

Jargule Jargule
Posts: 3

I am trying to write to a table:
document.getElementById("PV1".innerText = 'Open Circuit Voltage';
It works in Frontpage (stupid frontpage)
But nowhere else? Tried "publishing" that don't help.
All the color changes made via javascript functions work, just not the text?  Check it out here:
http://home.wi.rr.com/wisc2003/pv_powered2.htm
http://home.wi.rr.com/wisc2003/pv_powered2.htm
Use the select fields to make things happen.
Is it the stupid frontpage extensions causing issues?
Help!

Joe Gillespie Joe Gillespie
Posts: 528

You can't write text with CSS like this, you can only style text that is already there. To write text you have to use document.write() or set the text of a form element with JavaScript.

Jargule Jargule
Posts: 3

Can I use document.write to display some text inside a table (or cell) and not the entire page?
Can I create a form element inside the table cell and be able to display text there as a workaround?

Show me some source if can, thanks

Joe Gillespie Joe Gillespie
Posts: 528

jargule said:
Can I use document.write to display some text inside a table (or cell) and not the entire page?
Can I create a form element inside the table cell and be able to display text there as a workaround?

Show me some source if can, thanks


It is best to document.write the entire table otherwise you need a separate script inside each table cell.

You need to enclose the entire table code inside document.write("code" with the appropriate quotes and escaping the  necessary characters - there's some homework for you to do!

A form element inside every table cell is a very clumsy and ugly solution.

I don't use tables for layout anymore but you can see an example of document.write (in a div) at

http://www.minifonts.com/collection.html

I trust that you know how to view the source of a .js file?

Jargule Jargule
Posts: 3

I found a solution to use,  I can create new tables when I need them and not use/delete the ones I created in HTML.
function addCell()
{
  var x=document.getElementById('INVTable').rows[0]
  var y=x.insertCell(0);
  y.innerHTML= "some Text";
  x.style.fontFamily = "Lucida Bright";
  x.style.backgroundColor = 'E7B898';   // brownish
}
I want the page to only display these tables after the user makes some selections.
The next thing I want to do is display a background image (jpg) in one of the tables (once again, this was "possible" in FP) How can this be accomplished?
I am checking out the site and the js file thanks!

Joe Gillespie Joe Gillespie
Posts: 528

You are really going down a blind alley with this. innerHTML is an unofficial kludge - and at best, should contain HTML, not just text so 'some text' needs to be <p>Some text</p>. Expect it to break in many browsers. Use of innerHTML also screws-up the browser history. When someone hits the back button, they go back to the same page.

Specifying just 'Lucida Bright' for text is bad form. It should be

x.style.fontFamily = "Lucida Bright, Arial, sans-serif"; or whatever

Adding a background image to a table is going to cause you headaches too, it is no longer valid HTML and will display differently in the various browsers. It is best to put the table inside a div, which has the background image.

Maskodok Eko Maskodok Eko
Posts: 171

Adding a background image to a table is going to cause you headaches too, it is no longer valid HTML and will display differently in the various browsers. It is best to put the table inside a div, which has the background image.
TOP SEO | Jasa SEO Profesional

TOP SEO | Jasa SEO Profesional RajaPoker88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya IDRPoker.COM Agen Texas Poker dan Domino Online Indonesia Terpercaya POKERSTAR88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya D

You must login to reply