Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #35859
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Adding extra element "to option list" using next loop? |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <b1c258f0-0654-4352-ba33-6795f556807f@googlegroups.com> <c1f92b60-9792-489e-8016-3610d1e5d67b@googlegroups.com> |
| Date | 2018-11-26 13:05 +0100 |
| Message-ID | <XnsA9A6853F0457Aeejj99@194.109.6.166> (permalink) |
=?UTF-8?Q?Jonas_Th=C3=B6rnvall?= <jonas.thornvall@gmail.com> wrote on 26
Nov 2018 in comp.lang.javascript:
> Den lördag 24 november 2018 kl. 09:40:40 UTC+1 skrev Jonas Thörnvall:
>> I have a hard time understand the intrisic works of next loops, i use
>> exa
> mples i found on net onto create an optionlist of "devices".
>>
>> But i want to add an extra "option to the list of my own", but since i
>> do
> not understand the inner works of next loop, i am a bit stumped howto
> add my extra alternative to the option list. Here i try to add it
> before, and i also tried after. But i do not know howto position myself
> relative the next loop?
>>
>> Could someone please show me?
>>
>> var optout = document.createElement("option");
>> optout.text = "WEB SF2 SYNTH MY ADDED ADDED ALTERNATIVE";
>> document.getElementById("out_portsel").add(optout);
>> for (listoutput = Lportout.next(); listoutput && !listoutput.done; li
> stoutput = Lportout.next()) {
>> var deviceOut = listoutput.value.name;
>> optout.text = deviceOut;
>> document.getElementById("out_portsel").add(optout);
>> }
>
> What is the reason for this code not showing any element within loop
> just the extra added option? It seem to me it should add to the elements
> created in loop?
>
> var optout = document.createElement("option");
> for (listoutput = Lportout.next(); listoutput && !listoutput.done;
> listoutput = Lportout.next()) {
> var deviceOut = listoutput.value.name;
> optout.text = deviceOut;
> document.getElementById("out_portsel").add(optout);
> }
> test= document.getElementById("out_portsel");
> optout.text = "SF2 SYNTH WEB";
> test.add(optout);
You will need a NEW optout each time, meThinks():
[ES2015]
for (...) {
const optout = document.createElement("OPTION");
...
document.getElementById("out_portsel").appendChild(optout);
};
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Adding extra element "to option list" using next loop? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-11-24 00:40 -0800
Re: Adding extra element "to option list" using next loop? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-11-24 05:35 -0800
Re: Adding extra element "to option list" using next loop? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-11-25 19:57 -0800
Re: Adding extra element "to option list" using next loop? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-11-26 13:05 +0100
Re: Adding extra element "to option list" using next loop? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-11-26 22:45 -0800
Re: Adding extra element "to option list" using next loop? Jake Jarvis <pig_in_shoes@yahoo.com> - 2018-11-27 10:30 +0100
Re: Adding extra element "to option list" using next loop? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-11-27 12:08 +0100
Re: Adding extra element "to option list" using next loop? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-11-27 12:43 -0800
Re: Adding extra element "to option list" using next loop? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2018-11-27 23:39 +0100
Re: Adding extra element "to option list" using next loop? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2018-11-28 20:25 -0800
csiph-web