Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > How Do I Put the Greek Letter Pi on a Button?

Reply
Thread Tools

How Do I Put the Greek Letter Pi on a Button?

 
 
kvnsmnsn@hotmail.com
Guest
Posts: n/a
 
      02-03-2007
I'm trying to build a calculator in XHTML, and I've got a button that
currently reads "x <- pi", meaning load 3.141592654 into register x.
Is there some way to alter the button's label so that in the place of
"pi" I have the actual Greek letter pi? Any help on this would be
greatly appreciated.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_

 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      02-03-2007
Scripsit http://www.velocityreviews.com/forums/(E-Mail Removed):

> I'm trying to build a calculator in XHTML, and I've got a button that
> currently reads "x <- pi", meaning load 3.141592654 into register x.
> Is there some way to alter the button's label so that in the place of
> "pi" I have the actual Greek letter pi?


Yes, and you can even have a real arrow character instead of the clumsy
"<-".

<input type="button" id="compute" value="x &#x2190; &#x3c0;">

The above uses character references, with hexadecimal Unicode values. You
might find the following "mnemonic" alternative more readable as source:

<input type="button" id="compute" value="x &larr; &pi;">

Browser support tends to be fairly good these days, for relatively common
characters like the simple arrows and basic Greek letters.

Note, however, that common browser defaults may mean that the font used in
buttons is a sans-serif font where the letter small pi looks like
reduced-size capital pi, instead of the shape of small pi that people know
from math texts. Moreover, its typically in a small font size, smaller than
copy text! The following would usually help:

<style type="text/css">
input { font-family: Georgia, Times New Roman, serif; font-size: 100%; }
</style>

(You may wish to use class attribute on the <input> element and restrict the
styling to selected <input> elements only, using a class selector in CSS.)

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
 
 
 
J.O. Aho
Guest
Posts: n/a
 
      02-03-2007
(E-Mail Removed) wrote:
> I'm trying to build a calculator in XHTML, and I've got a button that
> currently reads "x <- pi", meaning load 3.141592654 into register x.
> Is there some way to alter the button's label so that in the place of
> "pi" I have the actual Greek letter pi? Any help on this would be
> greatly appreciated.


You could always try to use &pi; instead of your current pi

--

//Aho
 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      02-04-2007
kvnsmnsn wrote:

> Is there some way to alter the button's label so that in the place of
> "pi" I have the actual Greek letter pi?


If your page uses some form of Unicode character encoding (e.g. UTF-,
this should be fairly easy:

<input value="x ⇐ π">

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/CSS/Javascript/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      02-04-2007
>> Is there some way to alter the button's label so that in the place of
>> "pi" I have the actual Greek letter pi?


Just tried
<INPUT TYPE=submit VALUE='&pi;'>
which works on both my IE 6 and FF 1.5

Regards

Michael.


 
Reply With Quote
 
kvnsmnsn@hotmail.com
Guest
Posts: n/a
 
      02-06-2007
On Feb 3, 3:34 pm, "Jukka K. Korpela" <(E-Mail Removed)> wrote:

=The above uses character references, with hexadecimal Unicode values.
You
=might find the following "mnemonic" alternative more readable as
source:
=
=<input type="button" id="compute" value="x &larr; &pi;">

Thanks, Jukka, this worked great.

My next question is, is there a way in XHTML to print an arrow that
points both ways? Is there a "&rlarr;", maybe?

Also, how do you put subscripts and superscripts on buttons? I've
currently got an "x ^ y" that I would rather represent as "x" with "y"
as a superscript, and a "log_x y that I would rather represent as
"log" with "x" as a subscript.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      02-06-2007
Scripsit (E-Mail Removed):

> My next question is, is there a way in XHTML to print an arrow that
> points both ways? Is there a "&rlarr;", maybe?


Things don't work quite that way, by making up entities. In HTML, you can
use any Unicode character. A small minority of them has entity names defined
for them, but that's rather irrelevant. So basically you could take a look
at the Unicode block Arrows and then consider how widely the characters in
it are available in _fonts_ in common use; this is relevant, entities are
not. Incidentally, there are entities &harr; for left right arrow and &hArr;
for left right double arrow, and &harr; alias &#x2194; is probably what you
want, since it's basically the two-way counterpart of &larr;

(XHTML adds nothing but confusion to HTML, as far as practical use as
delivery format of web pages at present is considered.)

> Also, how do you put subscripts and superscripts on buttons?


There are Unicode characters for some subscripts and superscripts, but most
of them (beyond superscript 1, 2, and 3) are poorly supported in fonts, and
the repertoire is rather limited - there is no superscript y for example.

The other approach is to use <sub> or <sup> markup, but for that, you need a
context where markup (tags) are allowed, and a value="..." attribute (or any
attribute for that matter) is not such a context. There's the possibility of
using the <button> element, where you specify the button text as the content
of the element, where markup is allowed.

> I've currently got an "x ^ y" that I would rather represent as "x" with
> "y"
> as a superscript, and a "log_x y that I would rather represent as
> "log" with "x" as a subscript.


You could use

<button type="submit" name="foo" value="bar">
<var>x</var><sup><var>y</var></sup>
</button>
<hr>
<button type="submit" name="foo2" value="bar2">
log<sub><var>x</var></sub><var>y</var>
</button>

Beware that the rendering of button texts, especially with superscripts or
subscripts, can be rather awkward, so consider using a suitable style sheet
like

button { font-family: Verdana; font-size: 100%; }

The main problem with <button> is that Internet Explorer (including version
7) gets it fundamentally wrong. It does not send data like foo=bar or
foo2=bar2 as it should; instead it sends the name of the button followed by
an equals sign and the _content_ of the element, resulting in a mess
foo=%3CVAR%3Ex%3C%2FVAR%3E%3CSUP%3E%3CVAR%3Ey%3C%2 FVAR%3E%3C%2FSUP%3E
This may not matter if you can arrange things so that all the buttons have
unique names, so that you can look at the name part of the data only, or if
you use buttons other than submit buttons (e.g. <button type="button" ...>
for scripted buttons that are supposed to work using client-side JavaScript.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      05-09-2007
On 5 Feb 2007 16:03:01 -0800, (E-Mail Removed) wrote, quoted or
indirectly quoted someone who said :

>
>My next question is, is there a way in XHTML to print an arrow that
>points both ways? Is there a "&rlarr;", maybe?


see http://mindprod.com/jgloss/htmlcheat.html#ENTITIES
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      05-10-2007
Scripsit Roedy Green:

> On 5 Feb 2007 16:03:01 -0800, (E-Mail Removed) wrote, quoted or
> indirectly quoted someone who said :
>
>>
>> My next question is, is there a way in XHTML to print an arrow that
>> points both ways? Is there a "&rlarr;", maybe?

>
> see http://mindprod.com/jgloss/htmlcheat.html#ENTITIES


Sometimes it might make some sense to comment on a discussion three months
after others finished discussing it (and after correct answers to questions
were given), but that's hardly one of those cases. You are referring to your
page that contains many bogosities even on a casual look. Luckily you shout
in red: "I found the easiest way to learn HTML is to look at other people's
examples, to cut and paste from them, and to experiment by fiddling the
various parameters to see what the visual effects are." So anyone who takes
advice from you probably deserves all the mess he gets.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
Mike Duffy
Guest
Posts: n/a
 
      05-10-2007
"Jukka K. Korpela" <(E-Mail Removed)> wrote in
news:X5G0i.161720$(E-Mail Removed) i:

> Scripsit Roedy Green:
>
>> I found the easiest way to learn HTML is to look at other
>> people's examples, to cut and paste from them, and to experiment


> anyone who takes advice from you probably deserves all the mess he gets.


But he said it was the *easiest* way to learn HTML, not the *best* way.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
how to print the GREEK CAPITAL LETTER delta under utf-8 encoding =?gb2312?B?yMvR1MLkyNXKx8zs0cSjrM37vKvM7NHEsru8+7zS?= Python 8 05-29-2007 09:02 PM
Inputting Greek letter in textarea dungping HTML 27 09-02-2005 09:02 PM
olympus [mju:] 410 (greek letter mu) & USB driver, chinese? thufir Digital Photography 0 12-28-2004 08:33 PM
big letter -> small letter vertigo Python 4 07-06-2004 07:23 AM



Advertisments