Skip to content
Loading
how use return value function javascript in html'  
  • myHTML += '  
  • myHTML += '  
  • myHTML += 
  • '  
  • myHTML += '  
  • myHTML += Total Appels Entrants:  '  
  • myHTML += ' '  
  • myHTML += '  
  • myHTML +=  + allsite.libellé + '
     Du '
     + formatDate(document.getElementById("datedebut").value) + ' Au ' + formatDate(document.getElementById("datefin").value) + '
     Appels Locaux : 
     Appels nationaux : 
     Appels Internationaux : 
     Appels GSM :
     Appels Numéros spéciaux :"
     + data-toggle="tooltip" data-html="true"class="author fw-semi-bold" >Total Appels sortants : "AppelSortant">' + SiteStatList(allsite.site) + '  '  
  • myHTML += ' '  
  • myHTML += '  
  • myHTML += Coût Total: '  
  • myHTML += ' '  
  • myHTML += 
  • '  
  • myHTML += 
  • '  
  • myHTML += 
  • '  
  • myHTML += ' '  
  • myHTML += ''  
  • myHTML += ''  
  • myHTML += ''  
  • myHTML += ''  
  • });  
  • wrapperSite.innerHTML = myHTML;  
  • }  
  • for adding "total outgoing call" to each site in my view i creat the next javascript function :
    1. function SiteStatList(CodeSite) {  
    2. var apiurl = "http://localhost:14405/api/StatAppelSortantApi?G_CodeSite=" + CodeSite ;  
    3. $.ajax({  
    4. url: apiurl,  
    5. type: 'GET',  
    6. dataType: 'json',  
    7. success: function (d) {  
    8. TotalNbreAppellSortantBySite = d;  
    9. document.getElementById("AppelSortant").innerHTML = TotalNbreAppellSortantBySite;  
    10. },  
    11. error: function () {  
    12. alert("Error please try again");  
    13. }  
    14. });  
    15. }  
    i call this function in the next line :
    1. myHTML +=  + allsite.libellé + '
       Du '
       + formatDate(document.getElementById("datedebut").value) + ' Au ' + formatDate(document.getElementById("datefin").value) + '
       Appels Locaux : 
       Appels nationaux : 
       Appels Internationaux : 
       Appels GSM :
       Appels Numéros spéciaux :"
       + data-toggle="tooltip" data-html="true"class="author fw-semi-bold" >Total Appels sortants : "AppelSortant">' + SiteStatList(allsite.site) + '  '  
    normally the result I have if i call :function SiteStatList(CodeSite) 2 result :700 for site1 and 0 for site 2
     
    but the result is not good in my view i have 0 for site 1 and undifined for site2, maybe I didn't call my function well
     
    thanks for help

    3 Replies

    Know the answer? Post it — somebody with the same question will find it here.

    '  
  • myHTML += ' '  
  • myHTML += ' '  
  • myHTML += '  
  • myHTML += '  
  • myHTML += 
  • '  
  • myHTML += '  
  • myHTML += Total Appels Entrants:  '  
  • myHTML += ' '  
  • myHTML += '  
  • myHTML +=  + allsite.libellé + '
     Du '
     + formatDate(document.getElementById("datedebut").value) + ' Au ' + formatDate(document.getElementById("datefin").value) + '
     Appels Locaux : 
     Appels nationaux : 
     Appels Internationaux : 
     Appels GSM :
     Appels Numéros spéciaux :"
     + data-toggle="tooltip" data-html="true"class="author fw-semi-bold" >Total Appels sortants : "AppelSortant">CountAppelSortant '  
  • myHTML += ' '  
  • myHTML += '  
  • myHTML += Coût Total: '  
  • myHTML += ' '  
  • myHTML += 
  • '  
  • myHTML += 
  • '  
  • myHTML += 
  • '  
  • myHTML += ' '  
  • myHTML += ''  
  • myHTML += '
  • '  
  • myHTML += ''  
  • myHTML += ''  
  • });  
  • wrapperSite.innerHTML = myHTML;  
  • }  
  • function SiteStatList(CodeSite) {  
  • var apiurl = "http://localhost:14405/api/StatAppelSortantApi?G_CodeSite=" + CodeSite ;  
  • $.ajax({  
  • url: apiurl,  
  • type: 'GET',  
  • dataType: 'json',  
  • success: function (d) {  
  • TotalNbreAppellSortantBySite = d;  
  • },  
  • error: function () {  
  • alert("Error please try again");  
  • }  
  • });  
  • }  
  • allsite.site is site code for site1 the code is 001 and for site2 the code is 002, all value are correct,
    my problem how affect value  700 to site1 and 0 to site2
  • Sachin Singh
    In the line SiteStatList(allsite.site) what is allsite.site and how are you getting this value?
    If the value is correct then check the API response.