your code is wrong, getElementsByTagName returns an array. this works: 

private  native void n1()/*-{
        $wnd.alert(eval("document.getElementsByTagName('div')"));
}-*/;

I do not recommend to use eval. For accessing html DOM I recomment google dom 
java api, for example in your case:

private  void n2(String s1, String s2) {
        NodeList<Element> els = Document.get().getElementsByTagName(s1);
        for (int i = 0; i < els.getLength(); i++) {
                Element d1 = els.getItem(i);
                d1.getStyle().setBorderColor("red");
        }
}

regards


On Tue, 7 Feb 2012 04:42:41 -0800 (PST)
Jany <[email protected]> wrote:

> Hey,
> 
> the following code:
> 
> public void onModuleLoad() {
>               Element e = DOM.createElement("form");
>               e = RootPanel.getBodyElement().appendChild(e);
>               evalString(e.getNodeName().toLowerCase(), "item");
>       }
> 
> native void evalString (String s1, String s2)/*-{
>         a =  $wnd.document.getElementsByTagName(s1);
> 
>       $wnd.alert(a.item(0)); // I receive the correct value as result
>       $wnd.alert(eval('var t = a.' + "item" + '(0);' )); //here i receive
> "undefined" as result
> }-*/;
> 
> what do I wrong that the eval function do not return the correct
> value? Please help.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-web-toolkit?hl=en.
> 


-- 
Sebastian Gurin <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to