Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #12193

Re: How to programmatically display a value

From Dr J R Stockton <reply1208@merlyn.demon.co.uk>
Newsgroups comp.lang.javascript
Subject Re: How to programmatically display a value
Date 2012-02-26 20:38 +0000
Organization Home
Message-ID <mpQ2z2KwgpSPFwAc@invalid.uk.co.demon.merlyn.invalid> (permalink)
References <ji9cvn$pqa$1@dont-email.me> <ji9grj$a07$1@dont-email.me> <1403837.V9SEqChMir@PointedEars.de>

Show all headers | View raw


In comp.lang.javascript message <1403837.V9SEqChMir@PointedEars.de>,
Sat, 25 Feb 2012 13:19:29, Thomas 'PointedEars' Lahn
<PointedEars@web.de> posted:

OK, now we know how to deal with him.


The answers seen so far have ignored the most important consideration,
which is that of what the designer of the application wants the output
to look like.

Sometimes the output should form part of a running sentence, in which
case writing into a SPAN element is best. Or maybe an I or a B or a TT
element, if the output should be italic or bold or monospace; or CSS can
be used to style the element.

But if something resembling a form is used, perhaps with FIELDSETs,
buttons, checkboxes etc., it may well be appropriate to use an output
element that looks like a little window, such as is (or was) often found
on measuring instruments; and an INPUT TYPE=TEXT READONLY serves well
for that, especially if READONLY elements are given, as is done by
Safari, a slightly non-white background.


The two lines of code that someone gave to set an element with
getElementById and .innerHTML should, if used more than about twice, be
implemented in a function :
      function Wryt(ID, S) { document.getElementById(ID).innerHTML = S }
unless of course the reference is saved for future use.


The OP (and others) might read
<http://www.merlyn.demon.co.uk/js-faq-u.HTM#MaWP>.


> Cal Who wrote:
>
>> I don't know if this is the "best" way to display a numeral but I found
>> the innerHTML property on the span element and that appears to work OK.
>
>You are displaying a numeral, not parsing HTML markup; using innerHTML is
>overkill, not standardized, and therefore error-prone.  Use the `nodeValue'
>property of the `firstChild' of the span element object (you should provide
>it with a child node, say <span>&nbsp;</span>).
>
>Your learning to quote (at least, not to top-post) is a prerequesite for my
>further considering your postings.  You have been warned.

-- 
 (c) John Stockton, nr London UK.  ?@merlyn.demon.co.uk  DOS 3.3, 6.20; WinXP.
  Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links.
   PAS EXE TXT ZIP via  <http://www.merlyn.demon.co.uk/programs/00index.htm>
   My DOS  <http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to programmatically display a value " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-24 20:19 -0500
  Re: How to programmatically display a value " Cal Who" <CalWhoNOSPAM@roadrunner.com> - 2012-02-24 21:25 -0500
    Re: How to programmatically display a value Swifty <steve.j.swift@gmail.com> - 2012-02-25 06:46 +0000
    Re: How to programmatically display a value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-25 13:19 +0100
      Re: How to programmatically display a value Dr J R Stockton <reply1208@merlyn.demon.co.uk> - 2012-02-26 20:38 +0000
      Re: How to programmatically display a value Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-02-27 15:53 +0100
        Re: How to programmatically display a value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-02-27 17:40 +0100

csiph-web