Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 5th, 2004, 03:45 PM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pixel counting utility?

Does anyone know of a utility I can use to count the number of pixels in, say, a table cell?

  #2 (permalink)  
Old May 5th, 2004, 04:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

I dont think you would get one there. What is that for?

For a table cell, there are 2 ways to specify the width and height.

1) giving in pixel
2) giving in %age.

You can see that by viewing the source of the HTML in browser. You can't make that out if it's given in %age though. But as such you won't get any such utility to count the pixels in a table cell or so.

Good luck.

-Vijay G
  #3 (permalink)  
Old May 5th, 2004, 05:09 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think you could use the (IE only) property clientWidth.

The following example will show a message box saying that the width of the textbox is 196 pixels (because margin and border are not included in the clientWidth). Save to an HTML page, run it and click the button:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <title>Untitled Document</title>
  <script type="text/javascript">
  function SayWidth()
  {
    alert('Width is ' + document.getElementById('MyTableCell').clientWidth);
  }
  </script>
</head>
<body>
  <form id="frmTest">
  <table width="200px" border="1" id="MyTable" cellpadding="0" cellspacing="0">
  <tr>
    <td id="MyTableCell">&nbsp;</td>
  </tr>
  </table>
  <input type="button" value="Say Width" onClick="SayWidth();" />
</form>
</body>
</html>
The clientWidth will return the real width. So, if you put a large image inside the table cell, or unwrappable text, the table cell will grow and the clientWidth will report a wider table cell.
Look here for more information: http://msdn.microsoft.com/library/de...asp?frame=true

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Jam For the Ladies by Moby (Track 10 from the album: 18) What's This?
  #4 (permalink)  
Old May 5th, 2004, 06:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Imar,

Thanks for letting me know about such thing. I was wondering how one can get the width that way. Didnot get much on search too.

Thanks for that post.

Cheers!

-Vijay G
  #5 (permalink)  
Old May 5th, 2004, 10:57 PM
Authorized User
 
Join Date: Oct 2003
Location: , , .
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Specifically, it's for a site that uses asp. I have a table with data in it from a database, and I have another table at the top that I want to line up with the columns below it. So, I need to measure the number of pixels that the columns utilize so that I can hard code it in the table above it.

  #6 (permalink)  
Old May 6th, 2004, 02:17 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Vijay G

You're welcome. If you want to know more about this, take a look at Measure for Measure. It demonstrates all of the size properties available in IE, some of which are part of the DOM standard.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: It's Gonna Be A Beautiful Night by Prince (Track 6 from the album: Sign O The Times (Disk 2)) What's This?
  #7 (permalink)  
Old May 6th, 2004, 12:31 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks for the link Imar. That was useful.

-Vijay G


Similar Threads
Thread Thread Starter Forum Replies Last Post
pixel colour shanthi85 Beginning VB 6 0 May 22nd, 2007 11:23 AM
read bitmap pixel ersantombalak VB How-To 2 February 13th, 2007 07:20 AM
number pixel Perseus Beginning VB 6 1 August 11th, 2005 05:08 PM
Query Regarding the pixel CsharpHelp C# 0 May 16th, 2005 11:12 PM
pixel coordinates david.iulian Classic ASP Basics 0 March 31st, 2005 07:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.