How do you make a percentage bar

# Thread: How do you make a percentage bar

1. Junior Member
Join Date
Dec 1969
Posts
26

## How do you make a percentage bar

I am trying to display results of a poll using a percentage. I know how to get the percentage, but how can I make it look user friendly with a percentage bar. Do I need to make a bunch of GIF&#039;s and display the correct one accordingly, or can I do it much easier? For example<BR><BR>Poll Results:<BR><BR>Option 1<BR>&#124&#124&#124&#124&#124&#124&#124&#124&#124 &#124&#124 55%<BR><BR>Option 2<BR>&#124&#124&#124&#124 20%<BR><BR>Option 3<BR>&#124&#124&#124&#124&#124 25%

2. Senior Member
Join Date
Dec 1969
Posts
96,118

## Lots of ways...

I wrote one way:<BR><BR>http://www.clearviewdesign.com/Newbie.asp<BR><BR>See the demo on producing bar graphs.<BR><BR>That one is done without benefit of GIFs. It&#039;s probably easier to use GIFs.<BR><BR>If you have several one pixel by one pixel gifs, each in a different color, then you can just do:<BR><BR>&#060;IMG Src="red.gif" Width=220 Height=10&#062;<BR>&#060;IMG Src="blue.gif" Width=330 Height=10&#062;<BR>&#060;IMG Src="green.gif" Width=85 Height=10&#062;<BR><BR>The browser will quite happily "stretch" a 1x1 pixel gif to any size you want.<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
196

## RE: How do you make a percentage bar

Something like this maybe...<BR><BR><BR>- jørn<BR><BR><BR>&#060;%<BR> iPercent = 30 &#039; How many percent "filled"<BR> iWidth = 300 &#039; Width of percentbar<BR> <BR> iImageWidth = iPercent * iWidth / 100<BR>%&#062;<BR>&#060;img src="filledbar.gif" height=10 width="&#060;%=iImageWidth"&#062;&#060;img src="emptybar.gif" height=10 width="&#060;%=iWidth - iImageWidth"&#062;

4. Junior Member
Join Date
Dec 1969
Posts
26

## Thanks

I got it working using a 1x1 pixel GIF with Photoshop and with Bill&#039;s advice. Easier than I thought it would be.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•