Page 1 of 1

p:calendar and javascript value [SOLVED]

Posted: 21 Jan 2011, 00:29
by MikeK
I am trying to get the value of a Calendar into a javascript function but it is not working. I can get a value from a h:selectOneMenu on the same page. Can anyone tell me if this is possible?

Code: Select all

var test = document.getElementById("form1:statusDate").value;
<h:form id="form1">
     <p:calendar value="#{propDetail.prop.propStatusDate}" id="statusDate"  />
</h:form >

Re: p:calendar and javascript value

Posted: 21 Jan 2011, 15:01
by bumble.bee
If you take a look at the markup generated from a p:calendar (view page source) you'll notice that the id you specify goes to a span and the actual input element gets the id you specify appended with "_input". So in your example above the id of the input is "statusDate_input".

Re: p:calendar and javascript value

Posted: 21 Jan 2011, 15:22
by cagatay.civici
yourwidgetvar.getDate(), not sure when we've added this to the client side api though, exists in 2.2-SNAPSHOT at the moment. Also documented in PrimeFaces user's guide 2.2.

Re: p:calendar and javascript value

Posted: 21 Jan 2011, 16:19
by MikeK
Thank you both. Both of these solutions work well.