0
votes

I'm trying to call javascript native method getElementsByName to retrieve the list of all elements with the same name (name="").

Here is the code I'm using with Internet Explorer:

std::vector<FB::JSObjectPtr> nameList = DOMdoc->callMethod<std::vector<FB::JSObjectPtr> >("getElementsByName", FB::variant_list_of("name1");

No result is returned. By executing directly the method in javascript, I have the right number of items:

document.getElementsByName("name1")

I also tried to use directly the getElementById which works but returns only one element:

DOMdoc->getElementById("name1")->getJSObject();

Unfortunately I need to retrieve the list of elements for a radiobutton for exemple:

<input type="radio" name="name1" value="value1">Radio 1<br/>
<input type="radio" name="name1" value="value2">Radio 2<br/>
<input type="radio" name="name1" value="value3">Radio 3<br/>

Any help would be greatly appreciated,

Thanks.

UPDATE

Just tried with getElementsByTagName without more success:

nameList = DOMdoc->callMethod<std::vector<FB::JSObjectPtr> >("getElementsByTagName", FB::variant_list_of("name1"));
1
You don't have elements in code example with name="name"Pinal
Post updated. Of course the name was just an example.Bich0uill3

1 Answers

0
votes

You didn't specify which browser you're using; I'm guessing you're probably using IE. If not this may not help.

There are some methods like that that can't be called directly from a plugin in IE, you have to use the correct interface. That's why there is a special method on FB::DOM::Element for calling that method.

Try something like:

std::vector<FB::DOM::ElementPtr> nameList = DOMdoc->getElementsByTagName("name1");

I'm assuming, though you didn't specify, that you got DOMdoc by calling m_host->getDOMDocument()

Good luck