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
LBDDLBDD 

Javascript and S-Control, problem with LEFT !

Hello,

 

I have this code:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Title</title>
<script type="text/javascript" language="javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>
<script language="javascript">

function initPage() 
{
    window.setTimeout(PrepareSend, 200);
}

/* begin with 351 */
function Number351(numtmp){
  if ({!LEFT(numtmp,3)}!='351') return false; else return true;
}

/* verify 9 */
function Number9x(numtmp){
  if ({!LEFT(numtmp,1)}!='9') return false; else return true;
}

/* verify + sign */
function NumberPlus(numtmp){
  if ({!LEFT(numtmp,1)}!='+') return false; else return true;
}


function PrepareSend()
{
    try
    {
        if ({!Contact.MobilePhone} != '')
        {
            var thisMobile = {!Contact.MobilePhone};
            var thisDestination = '';  
            var thisOperator = '';            
            var thisMessage = 'Test from Salesforce';		
            var thisIs351 = Number351(thisMobile);
            var thisIs9x = Number9x(thisMobile);
            var thisIsPlus = NumberPlus(thisMobile);
	}            
      	window.setTimeout(reloadPage, 1000);
    }
    catch (error)
    {
        document.getElementById('_create_contact_').innerHTML = "Preparing Send - error: "+error; //.faultstring;
    }
}
</script>
</head>
</script>
</head>
<body onload="initPage();">
<div id='_create_contact_'>
<center>
&nbsp; &nbsp;<img src="/img/waiting_dots.gif" border="0" width=100 height=15>
</center>
</div>
</body>
</html>

 

I get error: "Error: The field numtmp not exist. Verify sintaxe."  [on funciton Number351(numtmp) ]

 

Before change to LEFT sintaxe, i used "if (numtmp.substr(0,3)!='351') { ... }", but get the ReferenceError, substr not exist!

 

Anyone can help or have a tip to resolve this?

 

Thanks a lot.

LB

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
b-Forceb-Force

please try this code

It is Syntax free :)

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Title</title>
<script type="text/javascript" language="javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>
<script language="javascript">

function initPage() 
{
    window.setTimeout(PrepareSend, 200);
}

/* begin with 351 */
function Number351(numtmp){
  if (numtmp.substr(0,3)!='351') return false; else return true;
}

/* verify 9 */
function Number9x(numtmp){
  if (numtmp.substr(0,1)!='9') 
return false; 
else 
return true;
}

/* verify + sign */
function NumberPlus(numtmp){
   if (numtmp.substr(0,1)!='+') return false; else return true;
}


function PrepareSend()
{
    try
    {
        if ({!Contact.MobilePhone} != '')
        {
            var thisMobile = {!Contact.MobilePhone};
            var thisDestination = '';  
            var thisOperator = '';            
            var thisMessage = 'Test from Salesforce';		
            var thisIs351 = Number351(thisMobile);
            var thisIs9x = Number9x(thisMobile);
            var thisIsPlus = NumberPlus(thisMobile);
	}            
      	window.setTimeout(reloadPage, 1000);
    }
    catch (error)
    {
        document.getElementById('_create_contact_').innerH​TML = "Preparing Send - error: "+error; //.faultstring;
    }
}
</script>
</head>
</script>
</head>
<body onload="initPage();">
<div id='_create_contact_'>
<center>
&nbsp; &nbsp;<img src="/img/waiting_dots.gif" border="0" width=100 height=15>
</center>
</div>
</body>
</html>

 

I tried same code in my dev org

It just show me waiting.........  image , I am not sure what is functionality :)

 

Hope this will help you

 

Thanks ,

Bala

All Answers

b-Forceb-Force

please try this code

It is Syntax free :)

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Title</title>
<script type="text/javascript" language="javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/13.0/connection.js" type="text/javascript"></script>
<script language="javascript">

function initPage() 
{
    window.setTimeout(PrepareSend, 200);
}

/* begin with 351 */
function Number351(numtmp){
  if (numtmp.substr(0,3)!='351') return false; else return true;
}

/* verify 9 */
function Number9x(numtmp){
  if (numtmp.substr(0,1)!='9') 
return false; 
else 
return true;
}

/* verify + sign */
function NumberPlus(numtmp){
   if (numtmp.substr(0,1)!='+') return false; else return true;
}


function PrepareSend()
{
    try
    {
        if ({!Contact.MobilePhone} != '')
        {
            var thisMobile = {!Contact.MobilePhone};
            var thisDestination = '';  
            var thisOperator = '';            
            var thisMessage = 'Test from Salesforce';		
            var thisIs351 = Number351(thisMobile);
            var thisIs9x = Number9x(thisMobile);
            var thisIsPlus = NumberPlus(thisMobile);
	}            
      	window.setTimeout(reloadPage, 1000);
    }
    catch (error)
    {
        document.getElementById('_create_contact_').innerH​TML = "Preparing Send - error: "+error; //.faultstring;
    }
}
</script>
</head>
</script>
</head>
<body onload="initPage();">
<div id='_create_contact_'>
<center>
&nbsp; &nbsp;<img src="/img/waiting_dots.gif" border="0" width=100 height=15>
</center>
</div>
</body>
</html>

 

I tried same code in my dev org

It just show me waiting.........  image , I am not sure what is functionality :)

 

Hope this will help you

 

Thanks ,

Bala

This was selected as the best answer
LBDDLBDD

Hello,

 

Thanks for reply.

 

I replace  {!LEFT()}   to javascript function  substr()  and work's fine. But the first time (before this create topic on discussion board) don't work, other problem maybe!

 

This code is to send SMS to customers from different operators, based on the number of mobile phone.

 

Regards,

LB

b-Forceb-Force

Hey,

Could you please share the code which sends sms

 

Thanks in advance,

Bala