Skip to main content
Nintex Community Menu Bar

JavaScript Concatenation

  • October 5, 2016
  • 7 replies
  • 8 views

kelliganp
Forum|alt.badge.img+10

Hi Folks,

I am tinkering around in our new Nintex Forms subscription and I was trying to concatenate some date parts to generate a date format. All of my function works except for one line (the 7th line with concat method). I am not a JS expert but this seems like the correct syntax. Can anyone tell me where I went wrong?

Also, is there a better way to represent code blocks in forum posts?

function loadStrDate(){
    var curDate = new Date();
    var curMonth = curDate.getMonth();
    var curDte = curDate.getDate();
    var curMSYear = curDate.getYear();
    var curYear = curMSYear + 1900;
    var strDate = curMonth.cancat("/",curDte,"/",curYear);
    NWF$('#'+ jsvar_strDate).val(strDate);
};

Thanks and regards,

Patrick Kelligan

7 replies

Forum|alt.badge.img+14
  • Scholar
  • October 6, 2016

try this

function loadStrDate(){
    var curDate = new Date();
    var curMonth = curDate.getMonth();
    var curDte = curDate.getDate();
    //var curMSYear = curDate.getYear();
    //var curYear = curMSYear + 1900;
    var curYear = curDate.getFullYear();
    var strDate = String(curMonth).concat("/",curDte,"/",curYear);
    NWF$('#'+ jsvar_strDate).val(strDate);
};

kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • October 6, 2016

That  did it! Thanks Marian!

How did you get the code block formatted like it is?


Forum|alt.badge.img+14
  • Scholar
  • October 6, 2016

happy.png


kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • October 6, 2016

Thanks Marian!


Forum|alt.badge.img+17
  • Nintex Partner
  • October 10, 2016
function loadStrDate(){
    var curDate = new Date();
    NWF$('#'+ jsvar_strDate).val((curDate.getMonth() + 1) + '/' + curDate.getDate() + '/' + curDate.getFullYear());
};‍‍‍‍‍‍‍‍

Forum|alt.badge.img+17
  • Nintex Partner
  • October 10, 2016

make sure you do the getMonth + 1 because its return value is from 0 to 11


kelliganp
Forum|alt.badge.img+10
  • Author
  • Rookie
  • October 12, 2016

Hi Andrew,

I incorporated your changes and it is much cleaner. Thanks for "+ 1" tip on the month!

Thanks and Regards,

Patrick