Board index JavaServer Faces General p:calendar and javascript value [SOLVED]

p:calendar and javascript value [SOLVED]

Components, Ajax Framework, Utilities and More.


Posts: 99
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?

var test = document.getElementById("form1:statusDate").value;
<h:form id="form1">
     <p:calendar value="#{propDetail.prop.propStatusDate}" id="statusDate"  />
</h:form >
Last edited by MikeK on 21 Jan 2011, 16:20, edited 1 time in total.
Prime Faces 4.0.1
Mojarra 2.2.4
Apache Tomcat 7.0.22
Internet Explorer 8, 9 10


Posts: 723
Location: United States
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".


Posts: 15102
Location: Cybertron

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.
PrimeFaces Lead


Posts: 99
Thank you both. Both of these solutions work well.
Prime Faces 4.0.1
Mojarra 2.2.4
Apache Tomcat 7.0.22
Internet Explorer 8, 9 10


Return to General