Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #40481 > unrolled thread

Get droplist index value by name?

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2021-10-14 23:41 -0700
Last post2021-10-15 00:18 -0700
Articles 4 — 1 participant

Back to article view | Back to comp.lang.javascript


Contents

  Get droplist index value by name? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 23:41 -0700
    Re: Get droplist index value by name? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 23:47 -0700
      Re: Get droplist index value by name? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-14 23:49 -0700
        Re: Get droplist index value by name? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-10-15 00:18 -0700

#40481 — Get droplist index value by name?

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-10-14 23:41 -0700
SubjectGet droplist index value by name?
Message-ID<d531c3e4-99ec-4c71-a5d8-ce0a28ade350n@googlegroups.com>
I have a dropdown "select option list" holding midi portIDs.
So reading the dropdown i know the name of available midiports.

I can visualy inspect to know the index of the ID i want. 

But how can i use the ID to retrieve the index?
ctrlportindex=parent.document.getElementById("parent.out_portsel").value // "FW1884 Control"

It is the the index of the Id of element out_portsel i am looking for?

Maybe i am doing it backward but i use the index to select output port.
In this case i know the "id" i want, but want is its index in the dropdownlist?

[toc] | [next] | [standalone]


#40482

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-10-14 23:47 -0700
Message-ID<d33cbe66-e870-45a0-aef2-7f17210312ffn@googlegroups.com>
In reply to#40481
fredag 15 oktober 2021 kl. 08:41:19 UTC+2 skrev Jonas Thörnvall:
> I have a dropdown "select option list" holding midi portIDs. 
> So reading the dropdown i know the name of available midiports. 
> 
> I can visualy inspect to know the index of the ID i want. 
> 
> But how can i use the ID to retrieve the index? 
> ctrlportindex=parent.document.getElementById("parent.out_portsel").value // "FW1884 Control" 
> 
> It is the the index of the Id of element out_portsel i am looking for? 
> 
> Maybe i am doing it backward but i use the index to select output port. 
> In this case i know the "id" i want, but want is its index in the dropdownlist?
I could probably loop through the id's equal to "x" and read out the index by loop counter.
But it seem a "A BIT IDIOTIC" if there already is a function for retrieving it.

[toc] | [prev] | [next] | [standalone]


#40483

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-10-14 23:49 -0700
Message-ID<49d14e22-efca-4684-9cdf-316a6ec0b085n@googlegroups.com>
In reply to#40482
fredag 15 oktober 2021 kl. 08:47:50 UTC+2 skrev Jonas Thörnvall:
> fredag 15 oktober 2021 kl. 08:41:19 UTC+2 skrev Jonas Thörnvall: 
> > I have a dropdown "select option list" holding midi portIDs. 
> > So reading the dropdown i know the name of available midiports. 
> > 
> > I can visualy inspect to know the index of the ID i want. 
> > 
> > But how can i use the ID to retrieve the index? 
> > ctrlportindex=parent.document.getElementById("parent.out_portsel").value // "FW1884 Control" 
> > 
> > It is the the index of the Id of element out_portsel i am looking for? 
> > 
> > Maybe i am doing it backward but i use the index to select output port. 
> > In this case i know the "id" i want, but want is its index in the dropdownlist?
> I could probably loop through the id's equal to "x" and read out the index by loop counter. 
> But it seem a "A BIT IDIOTIC" if there already is a function for retrieving it.
I give it 30 minutes "then i am going idiotic"

[toc] | [prev] | [next] | [standalone]


#40485

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-10-15 00:18 -0700
Message-ID<3e9171b6-50c5-441c-b8b1-96b2783465f5n@googlegroups.com>
In reply to#40483
fredag 15 oktober 2021 kl. 08:49:46 UTC+2 skrev Jonas Thörnvall:
> fredag 15 oktober 2021 kl. 08:47:50 UTC+2 skrev Jonas Thörnvall: 
> > fredag 15 oktober 2021 kl. 08:41:19 UTC+2 skrev Jonas Thörnvall: 
> > > I have a dropdown "select option list" holding midi portIDs. 
> > > So reading the dropdown i know the name of available midiports. 
> > > 
> > > I can visualy inspect to know the index of the ID i want. 
> > > 
> > > But how can i use the ID to retrieve the index? 
> > > ctrlportindex=parent.document.getElementById("parent.out_portsel").value // "FW1884 Control" 
> > > 
> > > It is the the index of the Id of element out_portsel i am looking for? 
> > > 
> > > Maybe i am doing it backward but i use the index to select output port. 
> > > In this case i know the "id" i want, but want is its index in the dropdownlist? 
> > I could probably loop through the id's equal to "x" and read out the index by loop counter. 
> > But it seem a "A BIT IDIOTIC" if there already is a function for retrieving it.
> I give it 30 minutes "then i am going idiotic"
Ok this is how it ended up.

function getPortIndex(){
	var e = parent.document.getElementById("out_portsel");
	for (var i=0;i<parent.out_portsel.length;i++){
			if (e.options[i].value=="FW1884 Control"){ctrlportindex=i; break;};	
	}
}

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web