p:calendar and javascript value [SOLVED]

Components, Ajax Framework, Utilities and More.
Post Reply
MikeK
Posts: 103
Joined: 13 Oct 2010, 15:07

21 Jan 2011, 00:29

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 >
Last edited by MikeK on 21 Jan 2011, 16:20, edited 1 time in total.
Prime Faces 6.0.14
Mojarra 2.2.14
Apache Tomcat 8.5.11
Internet Explorer 10,11

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

21 Jan 2011, 15:01

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".

User avatar
optimus.prime
Prime
Posts: 17422
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

21 Jan 2011, 15:22

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.

MikeK
Posts: 103
Joined: 13 Oct 2010, 15:07

21 Jan 2011, 16:19

Thank you both. Both of these solutions work well.
Prime Faces 6.0.14
Mojarra 2.2.14
Apache Tomcat 8.5.11
Internet Explorer 10,11

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Bing [Bot], siragott and 12 guests