function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DorababuDorababu 

javascript alert based on LanguageLocaleKey

I want to display Javascript alert when changes made in one tab are not saved and user moves to next tab. I am using the following code but nothing is displayed when i checked condition for language. Without this condition alert is displayed when user moves from one tab to another.

 

 

<scripttype="text/javascript" src="/soap/ajax/27.0/connection.js"></script>
<script type="text/javascript" >
var sid = getCookie('sid');
var server = "https://" + window.location.host + "/services/Soap/u/27.0";
  //initiate the connection
sforce.connection.init(sid, server);

var currentUser = sforce.connection.getUserInfo();
var result = sforce.connection.query('select LanguageLocaleKey from User where      id=\''+currentUser.getUserId+'\'');
var tab1 = document.getElementById('PPage:T1');
var tab2 = document.getElementById('PPage:T2');
var tab3 = document.getElementById('PPage:T3');
var tab4 = document.getElementById('PPage:T4');
var tab5 = document.getElementById('corpgridphone');
//alert('tabs '+tab1 +tab2 +tab3 +tab4);
var save1 = document.getElementsByName("inlineEditSave");
var cancel1 = document.getElementsByName("inlineEditCancel");
var edit2 = document.getElementById('PPage:ActformId:Actpg:Actpgb:EditButton');
var edit3 = document.getElementById('PPage:IntformId:Intpg:Intpgb:EditButton1');
var edit4 = document.getElementById('PPage:CLIformId:CLIpg:CLIpgb:EditButton2');
//alert('Edit Buttons '+edit2 +edit3 +edit4);
tab1.onclick = function() {
    if(edit2.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Accounts tab');}
            return false;
    }   
    if(edit3.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Interests tab');}
            return false;
    }
    if(edit4.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Client Information tab');}
            return false;
    }

}
tab2.onclick = function() {
    if(save1[0].style.display == 'inline'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Details tab');}
            return false;
    }       
    if(edit3.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Interests tab');}
            return false;
    }       

    if(edit4.style.display == 'none'){
    if(result == 'fr')
            {
                alert('S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails');
            }
            else if(result == 'en_US')
            {
            alert('Please save the changes in Client Information tab');}
            return false;
    }

}

 Any help will be greatly appreciated

 

digamber.prasaddigamber.prasad

Hi,

 

By looking into you code, seems issue is with escape character. Could you please try below alert statement:-

 

alert("S'il vous pla&#236;t enregistrer les modifications dans l'onglet D&#233;tails");

 Let me know if you still see issue.

 

Happy to help you!