Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36947
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: InnerHTML quirks |
| Date | 2019-06-27 17:26 +0200 |
| Message-ID | <gnk5heFmp4hU1@mid.individual.net> (permalink) |
| References | (1 earlier) <8b7e4e9a-6254-44c6-b06e-fdbec9930b32@googlegroups.com> <gnjcj3Fhe55U2@mid.individual.net> <9edf6537-5c4a-4259-8f47-1d6c2caad683@googlegroups.com> <gnjejeFhsacU1@mid.individual.net> <d45d565c-0875-4261-aafd-655c18962bb2@googlegroups.com> |
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:
<https://arnowelzel.de/en/tools/statistics>
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
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
InnerHTML quirks Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-26 22:51 -0700
Re: InnerHTML quirks Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-26 23:00 -0700
Re: InnerHTML quirks Arno Welzel <usenet@arnowelzel.de> - 2019-06-27 10:20 +0200
Re: InnerHTML quirks Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-27 01:53 -0700
Re: InnerHTML quirks Arno Welzel <usenet@arnowelzel.de> - 2019-06-27 10:55 +0200
Re: InnerHTML quirks Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-27 02:21 -0700
Re: InnerHTML quirks Arno Welzel <usenet@arnowelzel.de> - 2019-06-27 17:26 +0200
Re: InnerHTML quirks Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-27 01:59 -0700
Re: InnerHTML quirks Arno Welzel <usenet@arnowelzel.de> - 2019-06-27 11:01 +0200
Re: InnerHTML quirks Arno Welzel <usenet@arnowelzel.de> - 2019-06-27 10:18 +0200
Re: InnerHTML quirks Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-27 01:43 -0700
Re: InnerHTML quirks Arno Welzel <usenet@arnowelzel.de> - 2019-06-27 11:00 +0200
Re: InnerHTML quirks Silvio <silvio@internet.com> - 2019-06-27 15:05 +0200
csiph-web