Accessing <input> value in JavaScript -- namespace conflict?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing <input> value in JavaScript -- namespace conflict?

Hank Ratzesberger
I have not had any success with the JavaScript integration
as described in  http://www.orbeon.com/ops/doc/reference-xforms-ng 

"MyControl" is always undefined.  Then I noticed from the
thread http://www.mail-archive.com/orbeon-user%40lists.sourceforge.net/msg00995.html that:
You assign an id to the control with the xhtml:idWell, I am unable to do this.  My document root
is in the xhtml namespace:
<html xmlns="http://www.w3.org/1999/xhtml"
... />

But the following is "undefined" :

  <xforms:input id="lat-south" ref="lat-south">
    <xforms:label>South Lattitude:</xforms:label>
  </xforms:input>

  .....  

   alert( document.getElementById('lat-south').value );

I thought the id attribute is defined by the XML DTD
and not in the xhtml namespace?  When I attempt to force
it in that namespace:

  <xforms:input xhtml:id="lat-south" ref="lat-south"
      xmlns:xhtml="http://www.w3.org/1999/xhtml">
    <xforms:label>South Lattitude:</xforms:label>
  </xforms:input>

I get a null pointer exception in XFormsInputHandler.java (line 55).

This would not be the first time I have tripped over
namespace, but it seems like it should work.

Thanks all,
Hank
Goleta, CA






--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Accessing <input> value in JavaScript -- namespace conflict?

Erik Bruchez
Administrator
Hank,

I am trying this right now from a Javascript console. I have added an id
in the XForms Controls example:

<xforms:input ref="age" incremental="true" class="input" id="age-input">
     <xforms:label class="fixed-width">Age:</xforms:label>
     <xforms:hint>Positive number</xforms:hint>
</xforms:input>

and the following:

   document.getElementById('age-input').value

returns 35". Using alert() also works. So I am a little puzzled, I don't
know why it doesn't work in your case.

-Erik

Hank Ratzesberger wrote:

> I have not had any success with the JavaScript integration
> as described in  http://www.orbeon.com/ops/doc/reference-xforms-ng
> "MyControl" is always undefined.  Then I noticed from the
> thread
> http://www.mail-archive.com/orbeon-user%40lists.sourceforge.net/msg00995.html 
> that:
> You assign an id to the control with the xhtml:idWell, I am unable to do
> this.  My document root
> is in the xhtml namespace:
> <html xmlns="http://www.w3.org/1999/xhtml"
> ... />
>
> But the following is "undefined" :
>
>  <xforms:input id="lat-south" ref="lat-south">
>    <xforms:label>South Lattitude:</xforms:label>
>  </xforms:input>
>
>  .....
>   alert( document.getElementById('lat-south').value );
>
> I thought the id attribute is defined by the XML DTD and not in the
> xhtml namespace?  When I attempt to force
> it in that namespace:
>
>  <xforms:input xhtml:id="lat-south" ref="lat-south"      
> xmlns:xhtml="http://www.w3.org/1999/xhtml">
>    <xforms:label>South Lattitude:</xforms:label>
>  </xforms:input>
>
> I get a null pointer exception in XFormsInputHandler.java (line 55).
>
> This would not be the first time I have tripped over
> namespace, but it seems like it should work.
>
> Thanks all,
> Hank
> Goleta, CA
--
Orbeon - XForms Everywhere:
http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws