Help - Search - Members - Calendar
Full Version: Formatting ouput in <td>
HTMLHelp Forums > Programming > Client-side Scripting
rjhmille
How do I format the highlighted line in currency:

<script> //write the java script
var limit = parseInt(prompt("How many days?", "")); //define first variable
var total = .005; //define second variable
for(var days=1; days<=limit; days++) //define the count start
{
total = total+total; //formula for the running total
document.write("<tr>"); //output the table row
document.write("<td>"+days+"</td>"); //output first variable
document.write("<td>"+total+"</td>"); //output the second variable**************
document.write("</tr>"); //end table row
}

</script>
</table>
Christian J
Do you mean style the output with CSS?

rjhmille
I can do that but I want to stay with just html.
rjhmille
QUOTE(Christian J @ May 22 2017, 04:48 PM) *

Do you mean style the output with CSS?

I can do that but I want to stay with just html.
pandy
Let JS write a style attribute. If you can settle for HTML and CSS. wink.gif
Example below.

CODE
document.write("<td style='background: yellow'>"+total+"</td>"); //output the second variable
Christian J
QUOTE(rjhmille @ May 23 2017, 01:25 AM) *

QUOTE(Christian J @ May 22 2017, 04:48 PM) *

Do you mean style the output with CSS?

I can do that but I want to stay with just html.

You could write an HTML element inside the table cell. The B element might be semantically suitable in this case:

CODE
document.write("<td><b>"+total+"</b></td>");

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2019 Invision Power Services, Inc.