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 10:55:10 +0200 Lines: 47 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 nWc6xW4vusVhfiMW+U6rlQmffF0HM7GCsFnF4qnuYerQ6F/Uj3 Cancel-Lock: sha1:/L7saNkcEGo/JfBgAyY+e9zGMxY= In-Reply-To: <9edf6537-5c4a-4259-8f47-1d6c2caad683@googlegroups.com> Content-Language: en-US Xref: csiph.com comp.lang.javascript:36941 On 27.06.19 10:53, Jonas Thörnvall wrote: > Den torsdag 27 juni 2019 kl. 10:20:56 UTC+2 skrev Arno Welzel: >> On 27.06.19 08:00, Jonas Thörnvall wrote: >> >>> I have tried >>> document.getElementById('selBank').selectedIndex.innerHTML = 4 ; >> >> This is nonsense! >> >> You can either read it the index: >> >> myindex = document.getElementById('selBank').selectedIndex; >> >> or set it: >> >> document.getElementById('selBank').selectedIndex = 4; >> >> But using "innerHTML" is nonsense! Why do you even think, that >> "innerHTML" is used to set the index? >> >> >> >> -- >> Arno Welzel >> https://arnowelzel.de > > When you generate an option list dynamically and insert it with innerHTML Yes - than it *is* HTML. But the index is *not* HTML! It is just a number which you assign to the property "selectedIndex". > The "dynamically generated id selBank" is not available from main > Thus your suggested. > document.getElementById("selBansk").selectedIndex = 1; > > Will not work... That's why I also suggested adding the "selected" attribute for the selected option when you generate the HTML code. -- Arno Welzel https://arnowelzel.de