<script language="javascript">
function getSum() {
return 5+ 5; //an example
}
</script>
</head>
<body>
<table>
<tr>
<td>abc</td>
<td>def</td>
</tr>
<tr>
<td>Total:</td>
<td>(I want to put javascript value here)</td>
</tr>
</table>
</body>
[web] Using javascript, how to output total for variable to an already made table?
Hi, using javascript I want to output the value of a calculation into an existing table.
eg
<head>
How would I put a value there?, that is the bottom right field of the table.
Also I need to be able to dynamically change the value that is set there, as , say the user enters different numbers in a field(that I havent shown above) so I can constantly keep updating that total.
THanks
document.write( getSum() ); should do the trick. Just remember to encase it in script tags.
yeah, but say something else updates what the sum would be, how would i get it to recall the document.write(getsum())?
thanks
thanks
DHTML:
Let's say you have a bit of text you want to change.
You apply the ID parameter to the tag you want to play with; for example:
Would change the text in the <p> tag. You can also specify document.getElementById("changing").innerHTML to change it.
For a rolling demo; Here's my "placeholder" on my website.
Let's say you have a bit of text you want to change.
You apply the ID parameter to the tag you want to play with; for example:
<p id="changing">This is text</p><script>document.getElementById("changing").innerText = "Hello";</script>
Would change the text in the <p> tag. You can also specify document.getElementById("changing").innerHTML to change it.
For a rolling demo; Here's my "placeholder" on my website.
innerText removes HTML tags. If you edit the .innerHTML property, you will kill any HTML in the object, and just return and text. However, innerHTML is the actual HTML of an object. Try experimenting.
I think you're supposed to use the <span> tag instead of the <p> tag because you can't have paragraphs in tables (one block element inside another)
I think you're supposed to use the <span> tag instead of the <p> tag because you can't have paragraphs in tables (one block element inside another)
Quote:Original post by evolutional
Ben, your website killed my brain [wow]
[grin]
Nothing like some Radiohead nonsense. Hey, it needed *something* to be there...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement