Date picker for UI Page

kyrresc
Tera Expert

Hello,

I am working on implementing a date picker for a UI page. I have the following snippet in my HTML code-field:

<g:ui_date class = "form-control" id = "wt_start" name="work_time_start" value="${sysparm_start_date}"/>

Which displays like this:

find_real_file.png

which is fine. I am having issues retrieving this date in my client script. I have the following line:

var strDoc = gel("wt_start").value;

but it doesn't work... could anyone help?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@kyrresc 

you need to include the name attribute as well in the tag without which it won't work

so update as below

<g:ui_date class = "form-control" name="wt_start" id = "wt_start" name="work_time_start" value="${sysparm_start_date}"/>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@kyrresc 

you need to include the name attribute as well in the tag without which it won't work

so update as below

<g:ui_date class = "form-control" name="wt_start" id = "wt_start" name="work_time_start" value="${sysparm_start_date}"/>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Thanks alot! that solved it. 

Do the name attribute and id attribute in general need to be the same value?

Just to be on safer side keep both the name and the id attribute value as same.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader