16
Views
6
Comments
Solved
Date JavaScript
Question

Hello friends, how are you?


I have two doubts today! 


Firstly my Java Script Syntax Below:


"function DAF() {

    var data = new Date(),

        dia  = data.getDate().toString(),

        diaF = (dia.length == 1) ? '0'+dia : dia,

        mes  = (data.getMonth()+1).toString(), 

        mesF = (mes.length == 1) ? '0'+mes : mes,

        anoF = data.getFullYear();

        geral = diaF+"/"+mesF+"/"+anoF;

}"


In the line below:

  geral = diaF + "/" + mesF + "/" + anoF;




There is a syntax error he doesn't accept "/", could someone help me with this syntax?


I also have a local variable called DataJS in Outsystems


And I would like to know how I can assign the value of my variable geral in JS code 

to my Outsystems DataJS local variable.



Grateful for the help! this community is a Success!

mvp_badge
MVP
Rank: #91
Solution

Hi Kleber,

Please find the attached .oml solution file

- Set the Input widget style property in the extended properties section

   style = "display:none;"

   or set a StyleClass with "display:none;" definition


Refer this Forum Post: https://www.outsystems.com/forums/discussion/63166/how-to-bind-the-result-of-javascript-function-in-web-app-to-outsystem-local/#Post247289 


"function DAF() {
    var data = new Date(),
        dia  = data.getDate().toString(),
        diaF = (dia.length == 1) ? '0'+dia : dia,
        mes  = (data.getMonth()+1).toString(), 
        mesF = (mes.length == 1) ? '0'+mes : mes,
        anoF = data.getFullYear();
        geral = diaF+'/'+mesF+'/'+anoF;
        return geral;        
}

// assigning date value to the local variable
document.getElementById('" + Input_DateValue.Id + "').value = DAF(); 
"


See the sample app 

Hope this helps you!


Regards,

Benjith Sam

SampleAppDateJS.oml

Rank: #37350

Perfect!!! Tks!!

Rank: #37350


Now I have an Input with the date value, exactly what I wanted. How could I do in preparation to send this value to a Variable? I tried to place an assign after Java RunTime but it didn't work.


Tks!!