Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: InnerHTML quirks Date: Thu, 27 Jun 2019 17:26:38 +0200 Lines: 42 Message-ID: References: <6dcae054-0a58-4000-9bb0-0be37a937500@googlegroups.com> <8b7e4e9a-6254-44c6-b06e-fdbec9930b32@googlegroups.com> <9edf6537-5c4a-4259-8f47-1d6c2caad683@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net QPLjjfrGy8zlNYythIO9WwC214aTxitNFqUg1Hge8yyciwQfqk Cancel-Lock: sha1:s4x0QjmOtdBsNIpXXzEOD3HCJ+o= In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.javascript:36947 On 27.06.19 11:21, Jonas Thörnvall wrote: > Den torsdag 27 juni 2019 kl. 10:55:17 UTC+2 skrev Arno Welzel: [...] >> That's why I also suggested adding the "selected" attribute for the >> selected option when you generate the HTML code. > > Honestly Arno why the fuck would one have to do that, and that will only work for initiation, you could never use it to select any Well - you first asked how you can set the selected index when generating the options list. And this would be one solution. If you need to change the index afterwards - then use the selectedIndex property. However - you can also use the DOM to create a new select element with options as well and *then* using selectedIndex afterwards would work fine as well. As an example on how to manipulate the DOM: I did this on my own website to generate a dynamic chart on the fly: See the source for how the generic placeholder gets replaced by the chart canvas if the browser is able to support canvas elements at all. > Well i retract everything i said... It works perfectly well. > It was some months since i wrote the code and now i found, in code. > > defaultBank=0; > document.getElementById("selBank").selectedIndex = defaultBank; > ListBankInstruments(defaultBank); > > That is why it refused to change... It changed back... Well - problem solved ;-) -- Arno Welzel https://arnowelzel.de