The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Formatting ouput in <td>, trying to format <td>
rjhmille
post May 22 2017, 02:09 PM
Post #1





Group: Members
Posts: 5
Joined: 22-May 17
Member No.: 26,413



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>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 22 2017, 04:48 PM
Post #2


.
********

Group: WDG Moderators
Posts: 7,637
Joined: 10-August 06
Member No.: 7



Do you mean style the output with CSS?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
rjhmille
post May 22 2017, 06:25 PM
Post #3





Group: Members
Posts: 5
Joined: 22-May 17
Member No.: 26,413



I can do that but I want to stay with just html.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
rjhmille
post May 22 2017, 06:25 PM
Post #4





Group: Members
Posts: 5
Joined: 22-May 17
Member No.: 26,413



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post May 22 2017, 07:50 PM
Post #5


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,671
Joined: 9-August 06
Member No.: 6



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 22 2017, 08:56 PM
Post #6


.
********

Group: WDG Moderators
Posts: 7,637
Joined: 10-August 06
Member No.: 7



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>");

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th September 2017 - 01:20 AM