Input field not text not clearing in parent screen in Javascript

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!

BlockClearingIssue.zip

There are two ways -

  1. You can set the local variable and assign the value '' on action.
  2. use the below code if you need to clear the text in javascript

                 document.getElementById('<Input_InputText>').value=''

Regards,

Shahaji

mvp_badge
MVP

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

DateTimeRangePickerReactive_Block.oml

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.