Re: Javascript in an HTML table



[previous posting superseded in the face of new evidence]

Tom de Neef wrote:
"James Kimble" <jkimble@xxxxxxx> schreef in bericht
Yeah I'm sure this is a stupid question.
There are no stupid questions. There are only stupid answers.

Such as yours?

[...]
This just displays my graph by itself. No other table items appear.

Some suggestions:
<head>
<script type="text/JavaScript" src="bargraph.js"></script>

The <script ...> tag that was in the original code is missing here.

function createBarGraph() {
graph = new BarGraph("HorizBar");

`graph' should be declared a variable, globally if used outside of
createBarGraph(), locally if not.

// global declaration
var graph;

or

// local declaration and initialization
var graph = new BarGraph(...);

graph.values = "1000";
return graph.create()

The trailing `;' is missing; it is optional here, but recommended.

}
</script>
</head>

Chech the <script> tag for its attributes

You should be more precise and more verbose about your suggestions. The
point here is that the `type' attribute is required for the `script'
_element_, and it was not provided yet which renders the markup invalid.

document.write removed. Its intention is to replace the current page.

There is no intention of a method in itself; *people* have intentions. What
document.write() does, however, depends on where and when it is used, as
already explained before. (Please try to read all accessible postings of a
thread before you are posting late to it.)

That is not what you want.

True.

[...]
<td id=graphcell> </td>

All attribute values should be quoted.

[...]
That cell will be empty when loaded. In the onLoad handler you now call
script code that will fill the cell with your graph.
I.e. you could do with another function within your script:
function placeGraph(id)
{ var cell = document.getElementById(id)
cell.innerHTML = createBarGraph()
}

and with
<body onLoad="placeGraph('graphcell')">
it should work.

However, without further feature tests this is just a big overhead.

Of course, you can combine these things and use
<body
onLoad="document.getElementById(graphcell).innerHTML=createBarGraph()">

Needs to be

onLoad="document.getElementById('graphcell').innerHTML=createBarGraph()">

for a remote chance of working. (However, it would be better if
createBarGraph() and consequently graph.create() returned a reference to a
DOM Node object so that it can be inserted as child node of the element node
referred to by the equivalent of document.getElementById('graphcell'), and
maybe replace existing child nodes. It could not be done by the OP without
learning about DOM mutator methods.)

and do without the extra function if you really want to push your code
on the track of unmaintainability.

With your code it is on that track already.


PointedEars
--
Prototype.js was written by people who don't know javascript for people who
don't know javascript. People who don't know javascript are not the best
source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7@xxxxxxxxxxxxxxxx>
.



Relevant Pages

  • Re: Std Users, Update Files?
    ... This posting is provided "AS IS" with no warranties, and confers no rights. ... I use a VB script which simply points to a BAT file. ...
    (microsoft.public.windows.server.general)
  • Re: Setting registry data
    ... Manbinder Pal Singh ... This posting is provided "AS IS" with no warranties, ... I tried in google, but i was able to get codes in script format, not in ... this example shows how to read values from the registry but ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Metabase restore - how to tell if there is corruption?
    ... As your servers are clustering, you can synchronize the two metabases ... between the nodes using the following script: ... This posting is provided "AS IS" with no warranties, ...
    (microsoft.public.exchange.admin)
  • Re: Clearing down IE temp files, the easy way??
    ... but i use a script which sets the registry key and it works fine. ... Best regards ... Disclaimer: This posting is provided "AS IS" with no warranties, ...
    (microsoft.public.windows.terminal_services)
  • Re: rights issue perhaps ?
    ... When changed in the script to delete a computer object out of a container I have recently created it tells me that it cannot find the object. ... This posting is provided "AS IS" with no warranties, and confers no rights. ... only reply to Newsgroups ...
    (microsoft.public.windows.server.active_directory)