jsf - How to obtain the Date value from a p:calendar component in JavaScript? -


i don't know how obtain date value of <p:calendar> in primefaces component using javascript

this component

<p:calendar id="calendarinicio"             widgetvar="horainiciospin"             value="#{hbean.horainicial}" timeonly="true"              pattern="hh:mm" required="true"/> 

i need obtain hour value of component because i'm gonna send value other <p:calendar> component, using javascript. can give me idea? in advance...

primefaces provides powerful client side api. make use of it!

  1. add widgetname calendar. way way easier handle component on client side

    <p:calendar widgetvar="mycalendar" ... /> 
  2. write custom js, using primefaces client side api

    <h:form>      <p:calendar widgetvar="mycal1" timeonly="true" />      <p:calendar widgetvar="mycal2" timeonly="true" />      <p:commandbutton        onclick="var d = pf('mycal1').getdate(); d.sethours(d.gethours() + 1); pf('mycal2').setdate(d);" /> </h:form> 

inside js, able modify returned date according requirements , afterwards use .setdate() function set date in other calendar.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -