/    Sign up×
Community /Pin to ProfileBookmark

Can the tab be set using JavaScript?

Java has a function called setTabSize(). Does JavaScript have a similar function?

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@KorSep 22.2004 — 
Java has a function called setTabSize().
[/quote]

Which do what? (java and javascript are totally different languages... ? )
Copy linkTweet thisAlerts:
@jbotSep 22.2004 — [i]Originally posted by Kor [/i]

[B]Which do what? (java and javascript are totally different languages) [/B][/QUOTE]


yeah, but JS can code Java applets using LiveConnect.
Copy linkTweet thisAlerts:
@KorSep 22.2004 — My question was simple: [b]what[/b] is that java method doing, in able to see, as far as my/our knowledge are, which can be the javascript equivalent. Your comment, jbot, is usless, according to the situation.
Copy linkTweet thisAlerts:
@jbotSep 22.2004 — Your comment, jbot, is usless, according to the situation.[/QUOTE]

no, it's not.

i'm implying that he can script applets from Javascript, and therefore call Java's setTabSize() method.

this method sets the size of a tab in an applet or Java app. using Javascript within an HTML page, you could code the applet to change any applet tab. this is called LiveConnect (why don't you check it out before you start throwing platitudes about JS and Java not being conversant with each other).

now, of course, he might not want to be coding an applet. he may wanna create tabs in HTML and very well be mistaken that the similarities in names between JS and Java imply they also have similar objects, methods, properties, etc, in which case he'd be wrong. there is no tab tag in HTML and therefore no way to script one using JS (over and above using DHTML to simulate one).

hence there is no setTabSize() method in JS, because there are no tabs to create or alter. but that doesn't stop you from creating one, either to code your own DHTML tabs or else to script any given applet. that's wot i was harking at. but then again, you'd have known that if you weren't so prone to uttering the first thing that comes into your balkan bonce.
Copy linkTweet thisAlerts:
@Mike_BurdickauthorSep 22.2004 — This is what I'm trying to accomplish:

I have several one line read-only text fields that I'm using to output some numbers to. Because they are in a column, I would like the contents to be right justified. I thougth if I could use a tab, I could position them correctly - pad them so to speak. To tab, I would put an escape code for tab (09) in the string.

I know I could just put "spaces" in front of them but spaces are a fractional width of a normal character and thereby don't line the numbers up in all cases.

Yes, I also know I could use a div and get the effect I want but in my situation the read only input text field is best due to other restraints.

Thanks... Mike
Copy linkTweet thisAlerts:
@crh3675Sep 22.2004 — <input type="text" value="this is a &amp;#09;test">
Copy linkTweet thisAlerts:
@jbotSep 22.2004 — [i]Originally posted by Mike Burdick [/i]

[B]This is what I'm trying to accomplish:



I have several one line read-only text fields that I'm using to output some numbers to. Because they are in a column, I would like the contents to be right justified. I thougth if I could use a tab, I could position them correctly - pad them so to speak. To tab, I would put an escape code for tab (09) in the string.[/B]
[/QUOTE]


ahhhh ... i am mistaken on the tabs then.

well, try this:

[CODE]
String.prototype.indent=function(type,size)
{
var s="";

for (var i=0; i<size.length; i++)
{
switch (type)
{
case "chars": s+=" "; break;
case "tabs": s+="t"; break;
}
}
return s+this;
}[/CODE]


[COLOR=darkred]** code above has been edited **[/COLOR]

hope that helps ?
Copy linkTweet thisAlerts:
@Mike_BurdickauthorSep 22.2004 — jbot,

Thanks for responding.

Your function is nice but what I really need is some way to SET the tab value. The nice thing about using the tab is that it moves over a nember of character spaces which doesn't depend on the width like a space. I think the space width is something like 3/5 th's of a normal character.

For some reason if I use that tab escape value it moves over 5 character spaces. I would like to be able to set it to other values as needed.

Anyway, this may not be possible, and I may only be able to pad it with normal spaces.

-Mike
Copy linkTweet thisAlerts:
@jbotSep 23.2004 — [i]Originally posted by Mike Burdick [/i]

[B]

For some reason if I use that tab escape value it moves over 5 character spaces. I would like to be able to set it to other values as needed.



Anyway, this may not be possible, and I may only be able to pad it with normal spaces. [/B]
[/QUOTE]


i reckon what you want is determined by the browser on the application level and not the document level. hence that sorta functionality is probably outta reach.

the only other solution i can think of is to insert a span into any string derived from the field's value. the content of the span would be x number of spaces, the font size of which would 3/5 em sizes of the field's typeface. that sounds kinda convoluted tho, so i'm not gonna code that (i've got my own work to do after all).

anyway, as i understand it, a tab space is normally measured by x number of spaces. so, for example, in any text editor i may use to write HTML, i can set the tab size to 5 or 10 or whatever number of spaces i want.
Copy linkTweet thisAlerts:
@WebskaterSep 23.2004 — I may have missed the point - as others have not suggested this. You want the numbers inside text boxes to be right aligned?

<input type=text style="text-align:right" size=20>
Copy linkTweet thisAlerts:
@Mike_BurdickauthorSep 23.2004 — Webskater,

Thanks!!

I had no idea that the text field had that feature. I even searched the Internet, but nothing came up.

Now I'll have to see how many browers support it. I hope all.

Again, THANKS!

  • - Mike
  • Copy linkTweet thisAlerts:
    @KorSep 24.2004 — 
    I had no idea that the text field had that feature. I even searched the Internet, but nothing came up.
    [/quote]


    In fact text field has [b]not[/b] that "feature" as that "feature" is a CSS attribute, not a HTML one...

    http://www.w3schools.com/css/default.asp

    http://www.htmlhelp.com/reference/css/

    http://hotwired.lycos.com/webmonkey/authoring/stylesheets/tutorials/tutorial1.html

    All browsers support CSS. (Well there are some few attributes different treated by IE vs Moz, but not too many indeed).
    ×

    Success!

    Help @Mike_Burdick spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.5,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...