The CreatorCon Call for Content is officially open! Get started here.

Retrieve value from calendar (ui_date object)

avid
Kilo Expert

Hello.

I'm trying to Retrieve value from calendar to variable.

the calendar   object is this:

<g:ui_date class="form-control" name="end_date" id="end_date"   />

and the jelly syntax that supposed to retrieve the value into jvar_max variable is this:

<g:evaluate jelly="true" var="jvar_max">

                var date =gel('end_date').value;

                date;

    </g:evaluate>

I've also tried this:

<g:evaluate jelly="true" var="jvar_max">

      var date =document.getElementById('end_date').value;;

      date;

</g:evaluate>

But still, every time that i   send   jvar_max into angular function it's alerted as "null"

<form ng-submit="updateRecordList('${jvar_max}')" >


Thank you.

1 ACCEPTED SOLUTION

Hi.


I've tried   all of your suggestion' but nothing seems to work.


eventually i used this o the custom element on ui page:


<g:ui_date_custom title="date_pick" class="date-picker"


name="start_date_row1" id="start_date_row1" ng-model="numbers" value = "${gs.now()}" onchange="angular.element(this).scope().onload()"/>



I've created the element with the help of the post:   onchange event not working for ui_date field type in UI Page?




the   onchange event   call this angular function :



$scope.onload = function() {


  $scope.updateRecordList(document.getElementById('start_date_row1').value);


  };



Thank you for your help.


View solution in original post

5 REPLIES 5

bernyalvarado
Mega Sage

Hi Avi,



I believe you're mixing some concepts in here.



Keep in mind that the jelly script runs in the server to create that actual page in html that later is sent to the client to be run. I don't think you can do a getElementeById in your Jelly code since document is only available on the client side.



Thanks,


Berny


bernyalvarado
Mega Sage

Instead of doing the <g:evaluate> you're doing. Give a try to the following



  1. <form ng-submit="updateRecordList(end_date.value)" >  

or try


  1. <form ng-submit="updateRecordList(end_date)" >  


Thanks,


Berny


That's assuming that your calendar object actually has the date selected by the user once it's displayed at the client (the browser). Once the user does the submit of the form, then the form will use the respective end_date value as a parameter to call the updateRecordList method.



I hope this is helpful!



Thanks,


Berny


Hi.


I've tried   all of your suggestion' but nothing seems to work.


eventually i used this o the custom element on ui page:


<g:ui_date_custom title="date_pick" class="date-picker"


name="start_date_row1" id="start_date_row1" ng-model="numbers" value = "${gs.now()}" onchange="angular.element(this).scope().onload()"/>



I've created the element with the help of the post:   onchange event not working for ui_date field type in UI Page?




the   onchange event   call this angular function :



$scope.onload = function() {


  $scope.updateRecordList(document.getElementById('start_date_row1').value);


  };



Thank you for your help.