how to extract an date from an UI page ?

srinivasr
Mega Contributor

                    Below is extract of UI Page

                         

                          <g:ui_input_field type ="date" name="Alarm End Date" id="AlarmEndDate" label="Alarm End Date" value="${jvar_alarm_end_time}" mandatory="true" />                      

                                                  <td   style="padding-bottom:7px">                          

                          <g:ui_input_field type ="time" name="Alarm End Time" id="AlarmEndTime" label="Alarm End Time" value="${jvar_alarm_end_time}" mandatory="true" />                  

I am trying to read the values using :

var alarm_date = gel("AlarmEndDate").value;

var alarm_time = gel("AlarmEndTime").value;

Any suggestions on how to read the value?

1 ACCEPTED SOLUTION

Maheshwar Elang
Kilo Expert

How about the below?



1) Code


find_real_file.png



2) Screenshot of result (onLoad fetches current date time)


find_real_file.png



3) Works on onChange as well


find_real_file.png



Alert Message


find_real_file.png



Code snippet:


<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:ui_date_time name="end_date" id="end_date" value='${gs.nowDateTime()}' label="Alarm End Date &amp; Time" onChange="alertDateTime()" onload="alertDateTime()"/>



<script>


function alertDateTime()


{


  alert("Alarm DateTime - "+document.getElementById("end_date").value);


}


</script>


</j:jelly>




Please let me know if you face any issues.


View solution in original post

5 REPLIES 5

syedfarhan
Kilo Sage

Hi Ramakrishana,



You can try this , Hits: Always use small letters for passing an id i.e.:id=alarm_end_date and id=alarm_end_time.



var alarm_date = gel('alarm_end_date').value;


if (gel('alarm_end_date').value == ' ') {


alert("${JS:gs.getMessage('Please input your End Date')}");



var alarm_time =gel('alarm_end_time').vale;


if (gel('alarm_end_time').value == ' ') {


alert("${JS:gs.getMessage('Please input your End Time')}");




Thanks


i did try changing the id to small letters, but still have the same issue


Maheshwar Elang
Kilo Expert

Hi Srinivasa,



Your script should work. Just put your code in-between <script> tags.



<g:ui_input_field type ="date" name="Alarm End Date" id="AlarmEndDate" label="Alarm End Date" value="${jvar_alarm_end_time}" mandatory="true" />                    


<td   style="padding-bottom:7px">                        


<g:ui_input_field type ="time" name="Alarm End Time" id="AlarmEndTime" label="Alarm End Time" value="${jvar_alarm_end_time}" mandatory="true" />



<script>


var alarm_date = gel("AlarmEndDate").value;


var alarm_time = gel("AlarmEndTime").value;


alert("Alarm Date - "+alarm_date);


alert("Alarm Time - "+alarm_time);


</script>


i was not to get this working ... my field is in HTML and I need to access that from client script of the same page.