473,498 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tab Function Needed

Has anyone developed a function that can determine the width of a text
string using a proportional font? I would like to do this in order to
insert a variable number of spaces after the text to simulate a tab.

--
Dennis M. Marks
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #1
5 1424
"Dennis M. Marks" <de******@dcsi.net> writes:
Has anyone developed a function that can determine the width of a text
string using a proportional font? I would like to do this in order to
insert a variable number of spaces after the text to simulate a tab.


Before trying that, you should know that multiple spaces in HTML are
collapsed, and even if you use non-breaking spaces (which don't
collapse either) or a CSS whitespace setting that prevents it, you
can't aim precisely with spaces. Your "tabs" won't be aligned, because
you can only add an integer multiplum of the width of a space.

I would try to find another way of implementing "tabs".
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
swp
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<fz**********@hotpop.com>...
"Dennis M. Marks" <de******@dcsi.net> writes:
Has anyone developed a function that can determine the width of a text
string using a proportional font? I would like to do this in order to
insert a variable number of spaces after the text to simulate a tab.


Before trying that, you should know that multiple spaces in HTML are
collapsed, and even if you use non-breaking spaces (which don't
collapse either) or a CSS whitespace setting that prevents it, you
can't aim precisely with spaces. Your "tabs" won't be aligned, because
you can only add an integer multiplum of the width of a space.

I would try to find another way of implementing "tabs".
/L


perhaps I am misunderstanding what you are trying to do, but wouldn't
it be very easy to simulate this with a table that has borders turned
off?

swp
Jul 20 '05 #3
In article <fz**********@hotpop.com>, Lasse Reichstein Nielsen
<lr*@hotpop.com> wrote:
"Dennis M. Marks" <de******@dcsi.net> writes:
Has anyone developed a function that can determine the width of a text
string using a proportional font? I would like to do this in order to
insert a variable number of spaces after the text to simulate a tab.


Before trying that, you should know that multiple spaces in HTML are
collapsed, and even if you use non-breaking spaces (which don't
collapse either) or a CSS whitespace setting that prevents it, you
can't aim precisely with spaces. Your "tabs" won't be aligned, because
you can only add an integer multiplum of the width of a space.

I would try to find another way of implementing "tabs".
/L


I was able to do it using monospace fonts but I don't like the look of
the font. Can someone recommend the monospace font to use that would
look better?

http:www.dcs-chico.com/~denmarks/amtrak.html

There is a "tab" between the train name and station names in the first
select box.

P.S. It would still be nice to have a way to do it with proportional
fonts.

--
Dennis M. Marks
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #4
Dennis M. Marks wrote:
I was able to do it using monospace fonts but I don't like the look of
the font. Can someone recommend the monospace font to use that would
look better?
Use "Courier New" as first alternative. But the font renders very
small here anyway. And you should try not to use `px' but `em'.
Unfortunately, IE is unable to scale content formatted with font-size:...px;
There is a "tab" between the train name and station names in the first
select box.
There is nothing, not even a list if JavaScript is disabled or not
supported.
P.S. It would still be nice to have a way to do it with proportional
fonts.


Why don't you use a table? You *have* tabular data here. Use the
first column of the table as container for a group of radio buttons,
the second for the train name and the third for the description.
With a server-side application to process the selected train on submit,
you could accomplish this to be suitable for users with and without
client-side JavaScript support.
PointedEars
Jul 20 '05 #5
In article <a5*************************@posting.google.com> , swp
<DS******@aol.com> wrote:
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message
news:<fz**********@hotpop.com>...
"Dennis M. Marks" <de******@dcsi.net> writes:
Has anyone developed a function that can determine the width of a text
string using a proportional font? I would like to do this in order to
insert a variable number of spaces after the text to simulate a tab.


Before trying that, you should know that multiple spaces in HTML are
collapsed, and even if you use non-breaking spaces (which don't
collapse either) or a CSS whitespace setting that prevents it, you
can't aim precisely with spaces. Your "tabs" won't be aligned, because
you can only add an integer multiplum of the width of a space.

I would try to find another way of implementing "tabs".
/L


perhaps I am misunderstanding what you are trying to do, but wouldn't
it be very easy to simulate this with a table that has borders turned
off?

swp


I have a <form><select><option> list. The selection list contains train
name followed by first/last station. I wanted the latter to be tabbed
from the first. I was able to do it with a monospace font. See
http://www.dcs-chico.com/~denmarks/amtrak.com
I thought it would be nice to use a proportional font.

--
Dennis M. Marks
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1538
by: James Vanns | last post by:
Sounds nasty doesn't it!! Well it's kinda what I need to do! I have an external C struct (external to the C++ project/classes etc.) which is wants a function ptr assigned to one of it's members: ...
7
2222
by: Felix Kater | last post by:
Hi, when I need to execute a general clean-up procedure (inside of a function) just before the function returns -- how do I do that when there are several returns spread over the whole function?...
35
2407
by: michael.casey | last post by:
The purpose of this post is to obtain the communities opinion of the usefulness, efficiency, and most importantly the correctness of this small piece of code. I thank everyone in advance for your...
20
10717
by: spasmous | last post by:
main() { float * f; initialize_f(f); // ...use f for processing free(f); }
1
1753
by: Nacho | last post by:
Hello.. I have one problem with my reusable function to validate date.. I want to use this function to all my web project no validate date, but It's works fine if I have one textbox to...
3
3623
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
6
1395
by: J-P-W | last post by:
Hi, I have a function that looks up various values and then results in a value to a variable: Function ShouldItBeReferred If Claim3Date <"" Then 'Do stuff......
28
4270
by: Larax | last post by:
Best explanation of my question will be an example, look below at this simple function: function SetEventHandler(element) { // some operations on element element.onclick = function(event) {
5
2516
by: aaragon | last post by:
Hi everyone, I wrote a very simple function to try to understand the casting of variables in C++. The function is function foo() { std::vector<inttest(100); randomize(test); unsigned long...
32
3465
by: David Mark | last post by:
I've got a collection of functions that accept a function or object (paired with a method name) as a callback. For the longest time I have relied on this test. (typeof cb == 'function') ...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.