selectedIndex problems

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
User avatar
New php-forum User
New php-forum User
Posts: 15
Joined: Thu Aug 25, 2011 10:51 pm

Tue Jan 22, 2013 3:34 am

Ok, I have a problem that is (to my best guess) Javascript related.

I have a selectbox called 'nnummer' that is being populated when selectbox 'relatie' is being changed.
I do this via Javascript: first there is a <div> statement called 'nnummer' and when the selectbox 'relatie' is being changed, the function will replace the <div>'s innerHTML with the full <select> that is also called 'nnummer'.
This is working fine. But now I want to add a functionality.

On a certain moment I want to push an image that is calling again some Javascript.
A part of that function is to get Javascript to get the selectedIndex of 'relatie' and 'nnummer'.
Doing so with 'relatie' is no problem. When I use getElementById it gives back a [objectHTMLSelectElement] and I can get the selectedIndex of that.
But when I am getting getElementById("nnummer") it gives me back a [obectHTMLDivElement].
Sure it was a <div> element before, but on screen it is really a <select> element now because I did selected a nnummer.

So, my question to you all is, how do I get the selectedIndex of 'nnummer'.

If you want it to see the code fail, see the problem for real, it is behind a password protected page.
I can give you permission if you need to see it to help me solve the problem.


Post Reply