Hi, I have created a date range picker block. In a screen, I have created input field to select Date Range and passing the input field ID to block . In this block we are using Date Range Picker and realated Libraries.
In the same block , I have created a Button to clear the selected Date Range. I am trying to use javascript to clear the input field like " $('#' + $parameters.InputId + '').val = ''" and " document.getElementById('InputId').value = '' ". But its not working. Please suggest, how to clear selected input field from javascript.
The input field Id is passing from parent sceeen to block. Here I am attaching block oml and parent screen oml for reference. Changes requied in DateTimeRangePicker(Block)--> ClearOnClick(Client Action). Attached zip file contains block oml and application oml.Kindly suggest the solution and much appreciated.
Thanks in advance!
There are two ways -
document.getElementById('<Input_InputText>').value=''
Regards,
Shahaji
Hi Mahesh,
A slight code correction is required in the shared implementation to make it work. Below mentioned highlighted is the required code correction.
$(function() { $('#' + $parameters.InputId + '').val(''); }());
Instead of using the self invoked function, I would suggest a single statement to clear the input value.
$('#' + $parameters.InputId + '').val('');
or else you can go with the pure JS approach mentioned by Shahaji.
Refer to the attached oml
I hope this helps you!
Kind regards,
Benjith Sam