Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22255 > unrolled thread
| Started by | Une Bévue <unbewusst.sein@fai.invalid> |
|---|---|
| First post | 2013-12-08 11:54 +0100 |
| Last post | 2013-12-09 06:26 +0100 |
| Articles | 14 — 5 participants |
Back to article view | Back to comp.lang.javascript
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
| From | Une Bévue <unbewusst.sein@fai.invalid> |
|---|---|
| Date | 2013-12-08 11:54 +0100 |
| Subject | managing buttons |
| Message-ID | <l81j4h$7n4$1@shakotay.alphanet.ch> |
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.
[toc] | [next] | [standalone]
| From | Norman Peelman <npeelman@cfl.rr.com> |
|---|---|
| Date | 2013-12-08 08:10 -0500 |
| Message-ID | <l81r43$ens$1@dont-email.me> |
| In reply to | #22255 |
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) such as:
function ButtonsDisable(buttons)
{
foreach (buttons as button)
{
obj = document.getElementByID(button)
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"))
ButtonsEnable(array("S","C"))
Off the cuff code, may need tweaking 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("+"))
--
Norman
Registered Linux user #461062
AMD64X2 6400+ Ubuntu 10.04 64bit
[toc] | [prev] | [next] | [standalone]
| From | Une Bévue <unbewusst.sein@fai.invalid> |
|---|---|
| Date | 2013-12-08 15:03 +0100 |
| Message-ID | <l81u7t$1h2$1@shakotay.alphanet.ch> |
| In reply to | #22256 |
Le 08/12/13 14:10, Norman Peelman a écrit :
>
> So create functions that will enable and disable a passed array of
> objects (control names) such as:
>
>
> function ButtonsDisable(buttons)
> {
> foreach (buttons as button)
> {
> obj = document.getElementByID(button)
> 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"))
> ButtonsEnable(array("S","C"))
>
>
> Off the cuff code, may need tweaking 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("+"))
fine, thanks, that's a clever idae !
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2013-12-08 16:34 +0000 |
| Message-ID | <XnsA290B2B281B3eejj99@194.109.133.246> |
| In reply to | #22256 |
Norman Peelman wrote on 08 dec 2013 in comp.lang.javascript:
> 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) such as:
>
>
> function ButtonsDisable(buttons)
> {
> foreach (buttons as button)
> {
> obj = document.getElementByID(button)
> 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"))
> ButtonsEnable(array("S","C"))
>
>
> Off the cuff code, may need tweaking 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("+"))
Nice idea,
except that an id should start with a letter,
and cannot contain a +.
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2013-12-08 20:12 +0000 |
| Message-ID | <l82jsa$1ti$1@dont-email.me> |
| In reply to | #22258 |
On Sun, 08 Dec 2013 16:34:04 +0000, Evertjan. wrote: > Norman Peelman wrote on 08 dec 2013 in comp.lang.javascript: > >> 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. >> So create functions that will enable and disable a passed array of >> objects (control names) such as: > Nice idea, > except that an id should start with a letter, > and cannot contain a +. so just expand the ids out to something like: "addCatBtn", "rmvCatBtn", "edtCatBtn", "sveCatBtn", "cxlCatBtn", "addItmBtn", "rmvItmBtn", "edtItmBtn", "sveItmBtn", "cxlItmBtn" -- Denis McMahon, denismfmcmahon@gmail.com
[toc] | [prev] | [next] | [standalone]
| From | Norman Peelman <npeelman@cfl.rr.com> |
|---|---|
| Date | 2013-12-08 17:59 -0500 |
| Message-ID | <l82tkr$2m5$1@dont-email.me> |
| In reply to | #22258 |
On 12/08/2013 11:34 AM, Evertjan. wrote:
> Norman Peelman wrote on 08 dec 2013 in comp.lang.javascript:
>
>> 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) such as:
>>
>>
>> function ButtonsDisable(buttons)
>> {
>> foreach (buttons as button)
>> {
>> obj = document.getElementByID(button)
>> 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"))
>> ButtonsEnable(array("S","C"))
>>
>>
>> Off the cuff code, may need tweaking 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("+"))
>
> Nice idea,
> except that an id should start with a letter,
> and cannot contain a +.
>
Again, off the cuff code to get the idea out to the OP. I'm sure they
would have figured that out. If not, they'd be back.
--
Norman
Registered Linux user #461062
AMD64X2 6400+ Ubuntu 10.04 64bit
[toc] | [prev] | [next] | [standalone]
| From | Une Bévue <unbewusst.sein@fai.invalid> |
|---|---|
| Date | 2013-12-09 07:02 +0100 |
| Message-ID | <l83mee$arr$1@shakotay.alphanet.ch> |
| In reply to | #22264 |
Le 08/12/13 23:59, Norman Peelman a écrit :
> Again, off the cuff code to get the idea out to the OP. I'm sure they
> would have figured that out. If not, they'd be back.
from your idae, I'm testing a first implementation.
firstly, i define the states of my controller :
var states=['view_categories', 'add_category', ..., 'edit_item'];
secondly the ids of all of my buttons :
var buttons=['add_category', 'delete_category',..., 'save_item',
'cancel_item'];
and endly an object representing the enabled buttons per state of the
controller :
var buttonsEnabled={
view_categories: ['add_category']
...
, view_item: ['add_category', 'delete_category',
'edit_category', 'add_item', 'delete_item', 'edit_item']
, add_item: ['save_item', 'cancel_item']
, edit_item: ['save_item', 'cancel_item']
};
then, when the controller enters a new state i have to do :
state= "the new state";
and :
buttonsControl();
the function buttonsControl(), firstly disable all the buttons and
afterwards enables only the buttons following the state by buttonsEnabled.
[toc] | [prev] | [next] | [standalone]
| From | Une Bévue <unbewusst.sein@fai.invalid> |
|---|---|
| Date | 2013-12-09 06:24 +0100 |
| Message-ID | <l83k64$4vb$1@shakotay.alphanet.ch> |
| In reply to | #22258 |
Le 08/12/13 17:34, Evertjan. a écrit : > except that an id should start with a letter, > and cannot contain a +. in fact, it was a "symbolic" way to represent things. for example, the id of of button "+" is add_category|add_item.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2013-12-09 20:34 +0000 |
| Message-ID | <XnsA291DB81578BAeejj99@194.109.133.246> |
| In reply to | #22266 |
Une Bévue wrote on 09 dec 2013 in comp.lang.javascript:
> Le 08/12/13 17:34, Evertjan. a écrit :
>> except that an id should start with a letter,
>> and cannot contain a +.
> in fact, it was a "symbolic" way to represent things.
> for example, the id of of button "+" is add_category|add_item.
What as lame defence. Why not just say "sorry"?
To me it seems simply an error made either by incompetence or lazyness.
>>> obj = document.getElementByID(button)
[...]
>>> ButtonsDisable(array("+","-","E"))
This does not look like "symbolic" script.
[toc] | [prev] | [next] | [standalone]
| From | Norman Peelman <npeelman@cfl.rr.com> |
|---|---|
| Date | 2013-12-09 23:05 -0500 |
| Message-ID | <l863tj$e80$1@dont-email.me> |
| In reply to | #22271 |
On 12/09/2013 03:34 PM, Evertjan. wrote:
> Une Bévue wrote on 09 dec 2013 in comp.lang.javascript:
>
>> Le 08/12/13 17:34, Evertjan. a écrit :
>
>>> except that an id should start with a letter,
>>> and cannot contain a +.
>
>> in fact, it was a "symbolic" way to represent things.
>> for example, the id of of button "+" is add_category|add_item.
>
> What as lame defence. Why not just say "sorry"?
>
> To me it seems simply an error made either by incompetence or lazyness.
>
>>>> obj = document.getElementByID(button)
> [...]
>>>> ButtonsDisable(array("+","-","E"))
>
> This does not look like "symbolic" script.
>
Again, "off the cuff code...", "needs tweaking...". All you've
managed to do is tell the OP what he obviously already knew. I assumed
the OP would substitute their id/names appropriately and they did.
--
Norman
Registered Linux user #461062
AMD64X2 6400+ Ubuntu 10.04 64bit
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2013-12-10 08:55 +0000 |
| Message-ID | <XnsA29265035EB3Aeejj99@194.109.133.246> |
| In reply to | #22273 |
Norman Peelman wrote on 10 dec 2013 in comp.lang.javascript:
> On 12/09/2013 03:34 PM, Evertjan. wrote:
>> Une Bévue wrote on 09 dec 2013 in comp.lang.javascript:
>>
>>> Le 08/12/13 17:34, Evertjan. a écrit :
>>
>>>> except that an id should start with a letter,
>>>> and cannot contain a +.
>>
>>> in fact, it was a "symbolic" way to represent things.
>>> for example, the id of of button "+" is add_category|add_item.
>>
>> What as lame defence. Why not just say "sorry"?
>>
>> To me it seems simply an error made either by incompetence or
>> lazyness.
>>
>>>>> obj = document.getElementByID(button)
>> [...]
>>>>> ButtonsDisable(array("+","-","E"))
>>
>> This does not look like "symbolic" script.
>>
>
> Again, "off the cuff code...", "needs tweaking...". All you've
> managed to do is tell the OP what he obviously already knew. I assumed
> the OP would substitute their id/names appropriately and they did.
It seems you are rather mistaken about Usenet NGs, Norman.
This is not a helpdesk, though helping an OP is not forbidden or
anything and could even be quite a nice move, instead this group is a
discussion group, where the discussions form a hopefully valuable source
of learning for others, like newbees, for now and some years to come.
So irrespecably if the OP "obviously already knew" in the responder's
view, responses with errors in examples should not be made or duefully
corrected, [OR the responder could choose to answer the OP by private
mail].
Evertjan.
[toc] | [prev] | [next] | [standalone]
| From | Norman Peelman <npeelman@cfl.rr.com> |
|---|---|
| Date | 2013-12-10 07:07 -0500 |
| Message-ID | <l87071$dnn$1@dont-email.me> |
| In reply to | #22274 |
On 12/10/2013 03:55 AM, Evertjan. wrote:
> Norman Peelman wrote on 10 dec 2013 in comp.lang.javascript:
>
>> On 12/09/2013 03:34 PM, Evertjan. wrote:
>>> Une Bévue wrote on 09 dec 2013 in comp.lang.javascript:
>>>
>>>> Le 08/12/13 17:34, Evertjan. a écrit :
>>>
>>>>> except that an id should start with a letter,
>>>>> and cannot contain a +.
>>>
>>>> in fact, it was a "symbolic" way to represent things.
>>>> for example, the id of of button "+" is add_category|add_item.
>>>
>>> What as lame defence. Why not just say "sorry"?
>>>
>>> To me it seems simply an error made either by incompetence or
>>> lazyness.
>>>
>>>>>> obj = document.getElementByID(button)
>>> [...]
>>>>>> ButtonsDisable(array("+","-","E"))
>>>
>>> This does not look like "symbolic" script.
>>>
>>
>> Again, "off the cuff code...", "needs tweaking...". All you've
>> managed to do is tell the OP what he obviously already knew. I assumed
>> the OP would substitute their id/names appropriately and they did.
>
> It seems you are rather mistaken about Usenet NGs, Norman.
>
> This is not a helpdesk, though helping an OP is not forbidden or
> anything and could even be quite a nice move, instead this group is a
> discussion group, where the discussions form a hopefully valuable source
> of learning for others, like newbees, for now and some years to come.
>
> So irrespecably if the OP "obviously already knew" in the responder's
> view, responses with errors in examples should not be made or duefully
> corrected, [OR the responder could choose to answer the OP by private
> mail].
>
> Evertjan.
>
Then maybe that's what you should have said to begin with... I'll
keep that in mind.
--
Norman
Registered Linux user #461062
AMD64X2 6400+ Ubuntu 10.04 64bit
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-12-08 19:35 +0100 |
| Message-ID | <3066356.jABcFccoKv@PointedEars.de> |
| In reply to | #22256 |
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.
[toc] | [prev] | [next] | [standalone]
| From | Une Bévue <unbewusst.sein@fai.invalid> |
|---|---|
| Date | 2013-12-09 06:26 +0100 |
| Message-ID | <l83kaq$4vb$2@shakotay.alphanet.ch> |
| In reply to | #22259 |
Le 08/12/13 19:35, Thomas 'PointedEars' Lahn a écrit : > It is rather*pseudo-code* that needs*translation* into a programming > language. I've asked for an idae, not a solution...
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web