Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Janis Papanagnou 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: 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 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 ... 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