I have a hard time understand the intrisic works of next loops, i use examples i found on net onto create an optionlist of "devices".for (listoutput = Lportout.next(); listoutput && !listoutput.done; listoutput = Lportout.next())
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; listoutput = Lportout.next()) {
var deviceOut = listoutput.value.name;
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);
}
I have a hard time understand the intrisic works of next loops, i use examples i found on net onto create an optionlist of "devices".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?
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; listoutput = Lportout.next()) {
var deviceOut = listoutput.value.name;
optout.text = deviceOut;
document.getElementById("out_portsel").add(optout);
}
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 usemples i found on net onto create an optionlist of "devices".
exa
not understand the inner works of next loop, i am a bit stumped howto
But i want to add an extra "option to the list of my own", but since i
do
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?
stoutput = Lportout.next()) {
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
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);
=?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 usemples i found on net onto create an optionlist of "devices".
exa
not understand the inner works of next loop, i am a bit stumped howto
But i want to add an extra "option to the list of my own", but since i
do
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?
stoutput = Lportout.next()) {
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
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);
};
--Maybe i missunderstand you, but the loop reading ports/devices into the option list work just fine no matter how many ports devices i have.
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Den måndag 26 november 2018 kl. 13:05:57 UTC+1 skrev Evertjan.:
=?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
examples i found on net onto create an optionlist of "devices".
not understand the inner works of next loop, i am a bit stumped howto
But i want to add an extra "option to the list of my own", but since i >>>> do
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)
Maybe i missunderstand you, but the loop reading ports/devices into the option list work just fine no matter how many ports devices i have.
The problem arise when i want to add a pseudo port of my own to the list before, after or at index an index.
Before it will be overwritten in loop, after it will be the only option element.
JT
Am 27.11.2018 um 07:45 schrieb Jonas Thörnvall:
Den måndag 26 november 2018 kl. 13:05:57 UTC+1 skrev Evertjan.:
=?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, imples i found on net onto create an optionlist of "devices".
use exa
not understand the inner works of next loop, i am a bit stumped
But i want to add an extra "option to the list of my own", but since >>>>> i do
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?
stoutput = Lportout.next()) {
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
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)
Maybe i missunderstand you, but the loop reading ports/devices into the
option list work just fine no matter how many ports devices i have.
The problem arise when i want to add a pseudo port of my own to the
list before, after or at index an index.
Before it will be overwritten in loop, after it will be the only option
element. JT
If the node argument to appendChild *already* is in the document, it
will simply be moved to the new position.
Jake Jarvis <pig_in_shoes@yahoo.com> wrote on 27 Nov 2018 in comp.lang.javascript:Thanks Evertjan, it finally got thru my filter understanding what you were saying.
Am 27.11.2018 um 07:45 schrieb Jonas Thörnvall:
Den måndag 26 november 2018 kl. 13:05:57 UTC+1 skrev Evertjan.:
=?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, imples i found on net onto create an optionlist of "devices".
use exa
not understand the inner works of next loop, i am a bit stumped
But i want to add an extra "option to the list of my own", but since >>>>> i do
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?
stoutput = Lportout.next()) {
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
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)
Maybe i missunderstand you, but the loop reading ports/devices into the
option list work just fine no matter how many ports devices i have.
The problem arise when i want to add a pseudo port of my own to the
list before, after or at index an index.
Before it will be overwritten in loop, after it will be the only option
element. JT
If the node argument to appendChild *already* is in the document, it
will simply be moved to the new position.
That is why one should declare a NEW <OPTION> element each time,
or configure one's [= Jonas'es] Q better.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
But i really do ot understand the reason why i have to create a new "element?" to add something to an option list. Isn't it just indexed
strings, i mean optout.text is just a string?
<jonas.thornvall@gmail.com> wrote on 27 Nov 2018 in comp.lang.javascript:
But i really do ot understand the reason why i have to create a new "element?" to add something to an option list. Isn't it just indexed strings, i mean optout.text is just a string?
Such element becomes a node, when you insert/add/move it
at/to the right place in the DOM-tree.
The htmltext-file that is used to build up your page
is already parsed/executed and converted to a DOM-tree,
so forget about HTML-strings for now.
Now you are manipulating that DOM-tree [*1],
and each <option> is a new element/node,
and each "text" in that element is a new text-node.
So if you re-use an earlier created[!] node,
you lose the function it had.
So if you have 3 <option>-nodes and want a fourth and fiveth one,
you have to create TWO new ADDITIONAL nodes.
==============
[*1] if you use .innerHTML instead of DOM-commmands to insert something,
you in effect do a NEW parsing of that string, but that hampers your learning process as it does now, so better AVOID .innerHTML for now.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,007 |
Nodes: | 10 (0 / 10) |
Uptime: | 111:06:48 |
Calls: | 13,142 |
Files: | 186,574 |
D/L today: |
17,118 files (5,741M bytes) |
Messages: | 3,308,403 |