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


Groups > comp.lang.javascript > #32936

Appropriate event for change of a HTML selection list

Path csiph.com!aioe.org!.POSTED!not-for-mail
From Janis Papanagnou <janis_papanagnou@hotmail.com>
Newsgroups comp.lang.javascript
Subject Appropriate event for change of a HTML selection list
Date Tue, 4 Apr 2017 19:44:36 +0200
Organization Aioe.org NNTP Server
Lines 49
Message-ID <oc0m22$aa3$1@gioia.aioe.org> (permalink)
NNTP-Posting-Host luRcQWoE15S1nCoK16Zk6Q.user.gioia.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=iso-8859-15
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
X-Enigmail-Draft-Status N1110
X-Notice Filtered by postfilter v. 0.8.2
X-Mozilla-News-Host news://news.aioe.org:119
Xref csiph.com comp.lang.javascript:32936

Show key headers only | View raw


This post is (primarily) about which javascript event function should be used
in the context of a HTML selection list, and (secondarily) whether there's a
suggestion for a different approach.

The situation is as follows; I have a couple of HTML selection lists like

    <select id="I1" onchange="f(...)">
      <option value="0"> +0 </option>
      <option value="1"> +1 </option>
      ...

Whenever I change a value some computation f() is triggered by the function.

In addition to the above set of lists I have _one_ (similar) selection list

    <select id="setall" onchange="f_setall()">
      <option value="0"> +0 </option>
      <option value="1"> +1 </option>
      ...

to predefine all values (instead of using the individual select lists) for
convenience.

The use of 'onchange' is straightforward (and fine) for the first set of
lists but in the second single list (the one that should set the defaults)
it has an undesired effect; as designed it doesn't trigger the function if
the chosen value is the one already presently defined.

My use case is; if some of the first set of selection list values have
been changed I then want to set/reset all the values using the 'setall'
list.

I thought about two ways to handle that use case. a) Use an appropriate
existing other event type than 'onchange', but skimming through the list
https://www.w3schools.com/jsref/dom_obj_event.asp I did not found any.
And b), "invalidate" the value setting of the "setall" list when any of
the other selection lists had been triggered, so that subsequently using
"setall" will then be considered a change and 'onchange' triggered.

I am considering variant b) but if I missed some existing event function
I'd also use that, and pointers are welcome.

Currently, using 'onchange', I work around the issue by first selecting
any other value and then the desired value, but that is inconvenient.

(I hope the description is clear enough.)
Thanks in advance for all your useful replies.

Janis

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


Thread

Appropriate event for change of a HTML selection list Janis Papanagnou <janis_papanagnou@hotmail.com> - 2017-04-04 19:44 +0200
  Re: Appropriate event for change of a HTML selection list Julio Di Egidio <julio@diegidio.name> - 2017-04-04 12:05 -0700
    Re: Appropriate event for change of a HTML selection list Janis Papanagnou <janis_papanagnou@hotmail.com> - 2017-04-05 15:22 +0200
      Re: Appropriate event for change of a HTML selection list Julio Di Egidio <julio@diegidio.name> - 2017-04-05 07:12 -0700
        Re: Appropriate event for change of a HTML selection list Julio Di Egidio <julio@diegidio.name> - 2017-04-05 07:19 -0700
  Re: Appropriate event for change of a HTML selection list RobG <rgqld@iinet.net.au> - 2017-04-09 21:28 -0700
    Re: Appropriate event for change of a HTML selection list "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-04-10 10:38 +0200

csiph-web