AnsweredAssumed Answered

Clearing a Datepicker control on Javascript button click

Question asked by sptonintex on Oct 1, 2018
Latest reply on Oct 1, 2018 by sptonintex

I'm trying to use this button click to store the selections and the text entered in another field and clear out these selections immediately after. I've figured out how to get and move all values, and clearing the all the other fields out wasn't too difficult, but the Date Picker doesn't seem to want to clear out properly.

 

Any ideas on how to clear this field??

 

Associated fields:

jsDispositionBy - Choice Dropdown

jsDisposition - Choice Dropdown

jsDispositionDate - Date Picker

jsDispoComm - Multiline (Plain Text)

jsDispositionHist - Multiline (Plain Text)

 

setDispositionHist() - Save Disposition Button Client Click action

 

Before:

Before Save Disposition Click

After:

The function works as desired, except for reset of the Date Picker.

 

Where I found the displayed value of the Date Picker (Using Google Chrome Dev Tools:

 

 

Applicable functions:

function setDispositionHist(){
     var dispo = NWF$('#' + jsDisposition).find('option:selected').text();
     var dispoBy = NWF$('#' + jsDispositionBy).find('option:selected').text();
     var dispoDtval = parseDate(NWF$('#' + jsDispositionDate).val(),'mm/dd/yyyy');
     var dispocoTwo = NWF$('#' + jsDispoComm).val();
     var dispoHist = NWF$('#' + jsDispositionHist).val();
     var newdispco = dispo + '\n' + dispoBy + '\n' + dispoDtval + '\n' + dispocoTwo + '\n' + dispoHist;
     NWF$('#' + jsDispositionHist).val(newdispco);
     NWF$('#' + jsDispoComm).val('');
     var disBy = NWF$('#' + jsDispositionBy).find('option:selected').val();
     var disParse = NWF.RuntimeFunctions.parseLookup(disBy,true);
     setDispBy(jsDispositionBy,';#**SelectValue**');
     var dispval = NWF$('#' + jsDisposition).find('option:selected').val();
     var dispchs = NWF.RuntimeFunctions.parseLookup(dispval,true);
     setDispChs(jsDisposition,';#**SelectValue**');

function setDispBy(jsDispositionBy, value){
     NWF$(NWF$('#' + jsDispositionBy).siblings('select')[0]).val(NWF.RuntimeFunctions.parseLookup(value, true));
     NWF$('#' + jsDispositionBy).val(value);
}
function setDispChs(jsDisposition, value){
     NWF$(NWF$('#' + jsDisposition).siblings('select')[0]).val(NWF.RuntimeFunctions.parseLookup(value, true));
     NWF$('#' + jsDisposition).val(value);
}

function parseDate(dateString, userFormat){
     var delimiter, theFormat, theDate, month, date, year, dtString;
     userFormat = userFormat || 'mm/dd/yyyy';
     delimiter = /[^dmy]/.exec(userFormat)[0];
     theFormat = userFormat.split(delimiter);
     theDate = dateString.split(delimiter);
     for (var i = 0, len = theDate.length;i < len; i++){
          if (/d/.test(theFormat[i])){
               date = theDate[i];
          }
          else if (/m/.test(theFormat[i])){
               month = parseInt(theDate[i], 10);
          }
          else if (/y/.test(theFormat[i])){year = theDate[i];
          }
          }
          dtString = month + '/' + date +'/' + year;
          return dtString;
}

Outcomes