Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22259
| Message-ID | <3066356.jABcFccoKv@PointedEars.de> (permalink) |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Organization | PointedEars Software (PES) |
| Date | 2013-12-08 19:35 +0100 |
| Subject | Re: managing buttons |
| Newsgroups | comp.lang.javascript |
| References | <l81j4h$7n4$1@shakotay.alphanet.ch> <l81r43$ens$1@dont-email.me> |
Norman Peelman wrote:
> On 12/08/2013 05:54 AM, Une Bévue wrote:
>> on my page i have 10 buttons
>>
>> 5 for categories :
>> "+", "-", "E", "S", "C" for Add, Remove, Edit, Save and Cancel
>>
>> the same buttons for items.
>>
>> I'm looking for clever idaes on how to manage those buttons.
>>
>> I know how to enbale/disable the buttons but i'm confused on how to have
>> a clean and clever way to manage them versus the state of my JS.
>>
>> For example when I'm editing a category or an item, after having click
>> on "E", i want to disable "+", "-" and "E", letting "S" and "C" enabled.
>>
>> Also my "S" button serves two purposes : saving an updated category/item
>> or saving a modifies category/item
>>
>> Any help appreciated.
>
> So create functions that will enable and disable a passed array of
> objects (control names)
Control names are _not_ objects, they are primitive String values (DOMString
per DOM interface).
> such as:
>
>
> function ButtonsDisable(buttons)
It is customary in these languages that only names of functions that can be
called as a constructor, and constant-like variables or (in some
implementations) constants, start with a capital letter. (Constant-like
variables and constants are then distinguished from functions that can be
called as a constructor by the former's all-uppercase names.)
> {
> foreach (buttons as button)
There is no “foreach” statement in any widely known ECMAScript
implementation (there was “for each” in E4X, for which support unfortunately
has been abandoned by Mozilla recently). A possibility would be a for…in
statement, but a C-style “for” statement is more reliable here.
> {
> obj = document.getElementByID(button)
There is no document.getElementByID() method provided by any DOM
implementation. The property name is “getElementById”. Property names
usually are case-sensitive in these languages and their applications.
> obj.disabled = true
> }
> }
>
> function ButtonsEnable(buttons)
> {
> foreach (buttons as button)
> {
> obj = document.getElementByID(button)
> obj.disabled = false
> }
> }
>
> So that up entering the code for *Edit*ing you would call the functions
> like:
>
> ButtonsDisable(array("+","-","E"))
There is no array() function in ECMAScript. There is an Array()
constructor/factory that can be safely replaced with “[”…“]”, the Array
Initialiser.
> ButtonsEnable(array("S","C"))
>
>
> Off the cuff code, may need tweaking
It is rather *pseudo-code* that needs *translation* into a programming
language. Apparently you are confusing ECMAScript with some other language,
maybe with PHP (which you are equally challenged with, as your comp.lang.php
record shows).
> but that's the general idea. So
> I'm guessing that if 'categories' or 'items' is empty you would:
>
> ButtonsDisable(array("-","E","S","C"))
> ButtonsEnable(array("+"))
OMG. Will you *please* stop posting suggestions until you have gotten a
*minimum* clue?
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
managing buttons Une Bévue <unbewusst.sein@fai.invalid> - 2013-12-08 11:54 +0100
Re: managing buttons Norman Peelman <npeelman@cfl.rr.com> - 2013-12-08 08:10 -0500
Re: managing buttons Une Bévue <unbewusst.sein@fai.invalid> - 2013-12-08 15:03 +0100
Re: managing buttons "Evertjan." <exjxw.hannivoort@interxnl.net> - 2013-12-08 16:34 +0000
Re: managing buttons Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-08 20:12 +0000
Re: managing buttons Norman Peelman <npeelman@cfl.rr.com> - 2013-12-08 17:59 -0500
Re: managing buttons Une Bévue <unbewusst.sein@fai.invalid> - 2013-12-09 07:02 +0100
Re: managing buttons Une Bévue <unbewusst.sein@fai.invalid> - 2013-12-09 06:24 +0100
Re: managing buttons "Evertjan." <exjxw.hannivoort@interxnl.net> - 2013-12-09 20:34 +0000
Re: managing buttons Norman Peelman <npeelman@cfl.rr.com> - 2013-12-09 23:05 -0500
Re: managing buttons "Evertjan." <exjxw.hannivoort@interxnl.net> - 2013-12-10 08:55 +0000
Re: managing buttons Norman Peelman <npeelman@cfl.rr.com> - 2013-12-10 07:07 -0500
Re: managing buttons Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-08 19:35 +0100
Re: managing buttons Une Bévue <unbewusst.sein@fai.invalid> - 2013-12-09 06:26 +0100
csiph-web