Hey all,
I'm having some trouble with a select box.
I've got some dynamic stuff happening using DOM, in that I create various fields on the fly. One of those fields is a select box. As a matter of fact, that select box is an array.
Let's call that array property_value_method[].
I want to use DOM to cycle through this array of select boxes.
Here's what I got so far:
I want to get the value out, or even just get access to the selectedIndex or something, but I can't seem to cast it correctly.
I know that I've got the right pot_node (stands for potential node if you were wondering...), and I know that it is in fact a select box, but I want to know what the correct syntax is for casting this thing.
At least I think casting is the problem. If anyone can see some other problem, I'd appreciate the help.
One other implication if you were wondering why I don't just use:
is because I am using PHP and a field_forwarder, so I've potentially got more than one field named property_value_method[0], etc.. so that's why I'm resorting to using DOM to grab that information.
Here are some of my resources:
the cloneNode approach didn't work for me...
Thanks,
Sadiq.
I'm having some trouble with a select box.
I've got some dynamic stuff happening using DOM, in that I create various fields on the fly. One of those fields is a select box. As a matter of fact, that select box is an array.
Let's call that array property_value_method[].
I want to use DOM to cycle through this array of select boxes.
Here's what I got so far:
Code:
function displayProperties() { var pvm_list = document.getElementsByTagName("select"); for(var i = 0; i < pvm_list.length; i++) { var pot_node = pvm_list.item(i); if(pot_node.attributes.getNamedItem("name").value.match("property_value_method")) { var pvm_select = (HTMLSelectElement)pot_node.cloneNode(true); alert(pvm_select.value); } } }
I know that I've got the right pot_node (stands for potential node if you were wondering...), and I know that it is in fact a select box, but I want to know what the correct syntax is for casting this thing.
At least I think casting is the problem. If anyone can see some other problem, I'd appreciate the help.
One other implication if you were wondering why I don't just use:
Code:
for(var value in document.forms["app"].elements) { if(value.match("property_value_method")) { ... } }
Here are some of my resources:
the cloneNode approach didn't work for me...
Thanks,
Sadiq.
Comment