Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    OXY
    OXY is offline
    New Coder
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Variables starting with numbers - Workaround?

    Hi I have found the script below on this forum (http://www.codingforums.com/showthre...to_threadtools) and I´m using a form generated by a CRM system which I don´t have control over the way it names the form fields so I ended up with fields such as id="00N30000002PCO8" name="00N30000002PCO8".

    Since I read JavaScript doesn´t allow variables starting with numbers I wonder if there is a way of "making" it accept the variables starting with numbers or if there is a way of modifying the script below in order to read another tag such as alt="test" which I could use it as a controlled variable.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta name="generator" content="HTML Tidy for Windows (vers 1 June 2005), see www.w3.org">
    <meta http-equiv="Content-Language" content="en-au">
    <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>User info</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function SymError()
    {
      return true;
    }
    
    window.onerror = SymError;
    
    var SymRealWinOpen = window.open;
    
    function SymWinOpen(url, name, attributes)
    {
      return (new Object());
    }
    
    window.open = SymWinOpen;
    
    //-->
    </script>
    <script language="JavaScript" type="text/javascript">
        
          <!-- Begin
    function getParams() {
      var idx = document.URL.indexOf('?');
      if (idx != -1) {
        var tempParams = new Object();
        var pairs = document.URL.substring(idx+1,document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
          nameVal = pairs[i].split('=');
          tempParams[nameVal[0]] = nameVal[1];
        }
        return tempParams;
      }
    }
    var params = getParams();
    
            
          //  End -->            
    </script>
    </head>
    <body>
    <form method="post" name="myForm" action="--WEBBOT-SELF--" id="myForm">
        <!--webbot bot="SaveResults" U-File="C:\TEST\Tutorial\Emails sent\_private\form_results.csv" S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
        <p> Email:
            <input type="text" name="email" size="20">
        </p>
        <p> Account:
            <input type="text" name="cid" size="20">
        </p>
        <p>
            <input type="submit" value="Submit" name="B1">
            <input type="reset" value="Reset" name="B2">
        </p>
    </form>
    <script language="JavaScript" type="text/javascript">
       
          <!-- Begin
            pvName = unescape(params["email"]);
              if (pvName) document.myForm.email.value = pvName;            
    
            pvName = unescape(params["cid"]);
            if (pvName) document.myForm.cid.value = pvName;
          //  End -->
    
    </script>
    <script language="JavaScript" type="text/javascript">
    <!--
    var SymRealOnLoad;
    var SymRealOnUnload;
    
    function SymOnUnload()
    {
      window.open = SymWinOpen;
      if(SymRealOnUnload != null)
         SymRealOnUnload();
    }
    
    function SymOnLoad()
    {
      if(SymRealOnLoad != null)
         SymRealOnLoad();
      window.open = SymRealWinOpen;
      SymRealOnUnload = window.onunload;
      window.onunload = SymOnUnload;
    }
    
    SymRealOnLoad = window.onload;
    window.onload = SymOnLoad;
    
    //-->
    </script>
    </body>
    </html>
    I have tried the following but for some reason it does not work. It seems like the script only reads the "id" or "name" tags which are the ones I can´t modify.


    Code:
    pvAlt = unescape(params["protocolo"]);               
              if (pvAlt) document.SalesForce.test.value = pvAlt;
    You can find the script NOT working because of this problem at:
    http://www.liveperson.com.br/temp/we...=mail@host.com

    A really appreciate any help/reply

    Best Regards,
    OXY

  • #2
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    I don't really understand what you want. because your can store variables that start with numbers
    Code:
    var yourVar = '00N30000002PCO8';
    or you can make calls on these id's or name's as numbers
    Code:
    document.getElementById('00N30000002PCO8')

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Quote Originally Posted by ninnypants View Post
    I don't really understand what you want. because your can store variables that start with numbers
    Code:
    var yourVar = '00N30000002PCO8';
    or you can make calls on these id's or name's as numbers
    Code:
    document.getElementById('00N30000002PCO8')
    The name of a Javascript variable may not start with a digit. Obviously the content or value of that variable may begin with a digit.

    Likewise ID and NAME tokens must begin with a letter ([A-Za-z]).


    Quizmaster: In mythology, what term for a potion that increases sexual desire is derived from the name of the Greek godess of love?
    Contestant: Viagra

  • #4
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Code:
    for (var i=0; i<pairs.length; i++) {
          nameVal = pairs[i].split('=');
          tempParams[nameVal[0]] = nameVal[1];
        }
    If you change the above to this:
    Code:
    for (var i=0; i<pairs.length; i++) 
    {
      nameVal = pairs[i].split('=');
      if(nameVal[0].match/^\d/);
       nameVal[0] = 'x' + nameVal[0];
      tempParams[nameVal[0]] = nameVal[1];
    }
    It should prepend an 'x' to any parameter name that starts with a digit. Then you can adapt your subsequent code to expect that.

  • Users who have thanked Arty Effem for this post:

    OXY (08-02-2008)

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Quote Originally Posted by Arty Effem View Post
    If you change the above to this:
    Code:
    for (var i=0; i<pairs.length; i++) 
    {
      nameVal = pairs[i].split('=');
      if(nameVal[0].match/^\d/);
       nameVal[0] = 'x' + nameVal[0];
      tempParams[nameVal[0]] = nameVal[1];
    }
    It should prepend an 'x' to any parameter name that starts with a digit. Then you can adapt your subsequent code to expect that.
    Yes, but as I understand it the CRM system will not then recognise the name.
    Otherwise the OP could simply change the names of the variables and/or tokens by hand to anything he wants.

  • #6
    OXY
    OXY is offline
    New Coder
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Yes, but as I understand it the CRM system will not then recognise the name.
    Otherwise the OP could simply change the names of the variables and/or tokens by hand to anything he wants.
    Hi, Thank you all for your comments,

    Yes, Philip M is right, I cannot change the ID and Name variables in the form field so I was thinking about changing the code so it could identify the field from a different tag other than "ID" or "Name" such as Alt="test", if the script could look for the tag "Alt" as an Identifier then I would have a way to control the variable names.

    As I mentioned above I have tried the following, which should be enough to solve the problem of variables starting with numbers but it seems the script does not look for the "Alt" tag. Since I´m just a curious JavaScript user I don´t know how to make the script look for the "Alt" tag, it seems it only recognizes ID and Name tags, so I really need some help. Thanks.


    Code:
    pvAlt = unescape(params["protocolo"]);               
              if (pvAlt) document.SalesForce.test.value = pvAlt;

    Here is the whole code I´m using:
    Code:
    <html><head><title></title>
    <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1">
    <script type="text/javascript" src="http://www.liveperson.com.br/scripts/wforms_core.js"></script>
    <script type="text/javascript" src="http://www.liveperson.com.br/scripts/wforms_validation.js"></script>
    <script type="text/javascript" src="http://www.liveperson.com.br/scripts/wforms_onblur_validation.js"></script>  
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function SymError()
    {
      return true;
    }
    
    window.onerror = SymError;
    
    var SymRealWinOpen = window.open;
    
    function SymWinOpen(url, name, attributes)
    {
      return (new Object());
    }
    
    window.open = SymWinOpen;
    
    //-->
    </script>
    
    <script language="JavaScript" type="text/javascript">
        
          <!-- Begin
    function getParams() {
      var idx = document.URL.indexOf('?');
      var tempParams = new Object();
      if (idx != -1) {
        var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
          nameVal = pairs[i].split('=');
          tempParams[nameVal[0]] = nameVal[1];
        }
          return tempParams;
      }
    }
    var params = getParams();
    
            
          //  End -->            
    </script>
    
    
    
    <style type="text/css">
      .errFld {border: 2px solid #F00;}
      .errMsg {color: #C33; font-family: verdana; font-size: 11px; }
    </style>
    
    </head>
    
    <body>
    
    
    <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=ISO-8859-1" name=SalesForce method="POST">
    <input type=hidden name="oid" value="00D300000005zTX">
    <input type=hidden name="retURL" value="http://www.liveperson.com.br/confirma_demo.htm">
    <table cellpadding=0 cellspacing=4 border=0>
    <tr><td><label for="URL">Site:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="URL" maxlength="80" name="URL" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="first_name">Nome:</label></td><td bgcolor=red>&nbsp;</td><td><input id="first_name" maxlength="40" name="first_name" size="20" type="text" class="required"/></td></tr>
    
    <tr><td><label for="last_name">Sobrenome:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="email">Email:</label></td><td bgcolor=red>&nbsp;</td><td><input id="email" maxlength="80" name="email" size="20" type="text" class="validate-email required" /></td></tr>
    
    <tr><td><label for="phone">Telefone:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="phone" maxlength="40" name="phone" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="mobile">Celular:</label></td><td>&nbsp;</td><td><input  id="mobile" maxlength="40" name="mobile" size="20" type="text" /></td></tr>
    
    <tr><td><label for="company">Empresa:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="company" maxlength="40" name="company" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="street">Endere&ccedil;o:</label></td><td bgcolor=red>&nbsp;</td><td><textarea name="street" class="required" rows="5"></textarea></td></tr>
    
    <tr><td><label for="city">Cidade:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="city" maxlength="40" name="city" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="state">Estado:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="state" maxlength="20" name="state" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="zip">CEP:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="zip" maxlength="20" name="zip" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="industry">Segmento:</label></td><td bgcolor=red>&nbsp;</td><td><select  id="industry" name="industry" class="required"><option value="">-- Nenhum --</option><option value="Agência Online">Ag&ecirc;ncia Online</option>
    <option value="Agricultura">Agricultura</option>
    
    <option value="Alimentos e bebidas">Alimentos e bebidas</option>
    <option value="Assistência médica">Assist&ecirc;ncia M&eacute;dica</option>
    <option value="Bancos">Bancos</option>
    <option value="Call Center">Call Center</option>
    <option value="Comunicações">Comunica&ccedil;&otilde;es</option>
    <option value="Concessionária">Concession&aacute;ria</option>
    <option value="Construção Civil">Constru&ccedil;&atilde;o Civil</option>
    
    <option value="Consultoria">Consultoria</option>
    <option value="Corretora">Corretora</option>
    <option value="Educação">Educa&ccedil;&atilde;o</option>
    <option value="Eletrônica">Eletr&ocirc;nica</option>
    <option value="Energia">Energia</option>
    <option value="Engenharia">Engenharia</option>
    <option value="Entretenimento">Entretenimento</option>
    <option value="Equipamentos">Equipamentos</option>
    
    <option value="Expedição">Expedi&ccedil;&atilde;o</option>
    <option value="Finanças">Finan&ccedil;as</option>
    <option value="Governo">Governo</option>
    <option value="Hotelaria">Hotelaria</option>
    <option value="Imobiliário">Imobili&aacute;rio</option>
    <option value="Ind&uacute;stria">Ind&uacute;stria</option>
    <option value="ISP">ISP</option>
    
    <option value="Jogos/Games">Jogos/Games</option>
    <option value="Jurídico">Jur&iacute;dico</option>
    <option value="Livraria/Editora">Livraria/Editora</option>
    <option value="Manufatura">Manufatura</option>
    <option value="Meio ambiente">Meio ambiente</option>
    <option value="Mídia">M&iacute;dia</option>
    <option value="Outros">Outros</option>
    <option value="Produtos químicos">Produtos Qu&iacute;micos</option>
    
    <option value="Recreação">Recrea&ccedil;&atilde;o</option>
    <option value="Sa&uacute;de">Sa&uacute;de</option>
    <option value="Seguros">Seguros</option>
    <option value="Sem fins lucrativos">Sem fins lucrativos</option>
    <option value="Serviços">Servi&ccedil;os</option>
    <option value="Serviços p&uacute;blicos">Servi&ccedil;os p&uacute;blicos</option>
    
    <option value="Tecnologia">Tecnologia</option>
    <option value="Telecomunicações">Telecomunica&ccedil;&otilde;es</option>
    <option value="Transportes">Transportes</option>
    <option value="Turismo">Turismo</option>
    <option value="Varejo">Varejo</option>
    <option value="Vestuário">Vestu&aacute;rio</option>
    <option value="WebDesign">WebDesign</option>
    <option value="WebHosting">WebHosting</option>
    
    </select></td></tr>
    
    <tr><td>Nº de Atendentes:<br>(estimativa)</td><td bgcolor=red>&nbsp;</td><td><input  id="00N30000002PCb1" maxlength="25" name="00N30000002PCb1" size="20" type="text" class="required" /></td></tr>
    
    
    <tr><td>Vers&atilde;o:</td><td bgcolor=red>&nbsp;</td><td><input  id="00N30000002PCb8" maxlength="50" name="00N30000002PCb8" size="20" type="text" class="required" /></td></tr>
    
    <tr><td>Coment&aacute;rios:</td><td>&nbsp;</td><td><textarea  id="00N30000002PCb2" name="00N30000002PCb2" type="text" wrap="soft" rows="5"></textarea></td></tr>
    <tr><td>Protocolo de contato:</td><td bgcolor=red>&nbsp;</td><td><input Alt="test" disabled id="00N30000002PCO8" maxlength="51" name="00N30000002PCO8" size="20" type="text" /></td></tr>
    
    <tr><td colspan=3><br><input type="submit" name="submit" value="Requisitar Demo"></td></tr></table>
    </form>
    
    <script language="JavaScript" type="text/javascript">
    <!-- Begin
            pvName = unescape(params["site"]);               
              if (pvName) document.SalesForce.URL.value = pvName;            
    
            pvName = unescape(params["nome"]);               
              if (pvName) document.SalesForce.first_name.value = pvName;
    
            pvName = unescape(params["email"]);               
              if (pvName) document.SalesForce.email.value = pvName;
    
            pvName = unescape(params["telefone"]);               
              if (pvName) document.SalesForce.phone.value = pvName;
    
            pvName = unescape(params["empresa"]);               
              if (pvName) document.SalesForce.company.value = pvName;
    
            pvAlt = unescape(params["protocolo"]);               
              if (pvAlt) document.SalesForce.test.value = pvAlt;            
          //  End -->
    
    </script>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    var SymRealOnLoad;
    var SymRealOnUnload;
    
    function SymOnUnload()
    {
      window.open = SymWinOpen;
      if(SymRealOnUnload != null)
         SymRealOnUnload();
    }
    
    function SymOnLoad()
    {
      if(SymRealOnLoad != null)
         SymRealOnLoad();
      window.open = SymRealWinOpen;
      SymRealOnUnload = window.onunload;
      window.onunload = SymOnUnload;
    }
    
    SymRealOnLoad = window.onload;
    window.onload = SymOnLoad;
    
    //-->
    </script>
    
    </body>
    </html>

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    I am sorry say that it cannot be done. I am surprised that your CRM system generates ids which start with a digit and are thus invalid.

  • Users who have thanked Philip M for this post:

    OXY (08-02-2008)

  • #8
    OXY
    OXY is offline
    New Coder
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    I am sorry say that it cannot be done. I am surprised that your CRM system generates ids which start with a digit and are thus invalid.
    Hi Philip M, I really appreciate your time and effort.

    I guess I will have to try a language that accepts variables starting with numbers. Hopefully PHP. I found it odd that this was the only script I could find that would do this simple task.

    Thanks again,

    OXY

  • #9
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    No problem - glad to assist.
    But PHP is exactly like Javascript. Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

    Here is an idea which may or may not work. Use ArtyEffem's script to prepend an x to all variables and tags, then onsubmit run another script to delete the x again and restore them to their original all-numeric names.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Last edited by Philip M; 08-02-2008 at 06:53 PM.

  • Users who have thanked Philip M for this post:

    OXY (08-02-2008)

  • #10
    OXY
    OXY is offline
    New Coder
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    No problem - glad to assist.
    But PHP is exactly like Javascript. Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores.

    Here is an idea which may or may not work. Use ArtyEffem's script to prepend an x to all variables and tags, then onsubmit run another script to delete the x again and restore them to their original all-numeric names.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
    Hi Philip M, great idea, I will modify the script according ArtyEffem´s suggestion but unfortunatly I´m not a coder so I have no idea how to make the onsubmit action you suggested. I will google around to see if I can learn it but any help will be very handy.

    Thanks, again..

    OXY

  • #11
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,300
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Something like:-

    Code:
    <form  ...  onsubmit = "killx()";
    
    function killx () {
    for (var i=0; i < pairs.length; i ++) {
    nameVal = pairs[i].split('=');
    if (nameVal[0].match/^x/) {
    nameVal[0] =  nameVal[0].replace(/^x/, "");
    }
    }
    }

  • #12
    OXY
    OXY is offline
    New Coder
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Something like:-

    Code:
    <form  ...  onsubmit = "killx()";
    
    function killx () {
    for (var i=0; i < pairs.length; i ++) {
    nameVal = pairs[i].split('=');
    if (nameVal[0].match/^x/) {
    nameVal[0] =  nameVal[0].replace(/^x/, "");
    }
    }
    }
    Hi,
    Thanks Philip M, I could not make it work , sorry, so I decided not to use Arty Effem's script and set the x manually on one field "name" hoping the "killx" function would do it's job but my CRM system is not receiving the info so I guess the "x" is not being removed. It recieves the info correctly when I don't use the script.

    I wonder if you could take a look at the whole thing and see if there is still any hope..

    Code:
    <html><head><title></title>
    <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1">
    <script type="text/javascript" src="http://www.liveperson.com.br/scripts/wforms_core.js"></script>
    <script type="text/javascript" src="http://www.liveperson.com.br/scripts/wforms_validation.js"></script>
    <script type="text/javascript" src="http://www.liveperson.com.br/scripts/wforms_onblur_validation.js"></script>  
    
    <script language="JavaScript" type="text/javascript">
    function killx () {
    for (var i=0; i < pairs.length; i ++) {
    nameVal = pairs[i].split('=');
    if (nameVal[0].match/^x/) {
    nameVal[0] =  nameVal[0].replace(/^x/, "");
    }
    }
    }
    </script>
    
    
    <script language="JavaScript" type="text/javascript">
        
          <!-- Begin
    function getParams() {
      var idx = document.URL.indexOf('?');
      var tempParams = new Object();
      if (idx != -1) {
        var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
          nameVal = pairs[i].split('=');
          tempParams[nameVal[0]] = nameVal[1];
        }
          return tempParams;
      }
    }
    var params = getParams();
    
            
          //  End -->            
    </script>
    
    
    
    <style type="text/css">
      .errFld {border: 2px solid #F00;}
      .errMsg {color: #C33; font-family: verdana; font-size: 11px; }
    </style>
    
    </head>
    
    <body>
    
    
    <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=ISO-8859-1" name=SalesForce method="POST" onsubmit = "killx();">
    <input type=hidden name="oid" value="00D300000005zTX">
    <input type=hidden name="retURL" value="http://www.liveperson.com.br/confirma_demo.htm">
    <table cellpadding=0 cellspacing=4 border=0>
    <tr><td><label for="URL">Site:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="URL" maxlength="80" name="URL" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="first_name">Nome:</label></td><td bgcolor=red>&nbsp;</td><td><input id="first_name" maxlength="40" name="first_name" size="20" type="text" class="required"/></td></tr>
    
    <tr><td><label for="last_name">Sobrenome:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="last_name" maxlength="80" name="last_name" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="email">Email:</label></td><td bgcolor=red>&nbsp;</td><td><input id="email" maxlength="80" name="email" size="20" type="text" class="validate-email required" /></td></tr>
    
    <tr><td><label for="phone">Telefone:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="phone" maxlength="40" name="phone" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="mobile">Celular:</label></td><td>&nbsp;</td><td><input  id="mobile" maxlength="40" name="mobile" size="20" type="text" /></td></tr>
    
    <tr><td><label for="company">Empresa:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="company" maxlength="40" name="company" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="street">Endere&ccedil;o:</label></td><td bgcolor=red>&nbsp;</td><td><textarea name="street" class="required" rows="5"></textarea></td></tr>
    
    <tr><td><label for="city">Cidade:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="city" maxlength="40" name="city" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="state">Estado:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="state" maxlength="20" name="state" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="zip">CEP:</label></td><td bgcolor=red>&nbsp;</td><td><input  id="zip" maxlength="20" name="zip" size="20" type="text" class="required" /></td></tr>
    
    <tr><td><label for="industry">Segmento:</label></td><td bgcolor=red>&nbsp;</td><td><select  id="industry" name="industry" class="required"><option value="">-- Nenhum --</option><option value="Agência Online">Ag&ecirc;ncia Online</option>
    <option value="Agricultura">Agricultura</option>
    <option value="Alimentos e bebidas">Alimentos e bebidas</option>
    <option value="Assistência médica">Assist&ecirc;ncia M&eacute;dica</option>
    <option value="Bancos">Bancos</option>
    <option value="Call Center">Call Center</option>
    <option value="Comunicações">Comunica&ccedil;&otilde;es</option>
    <option value="Concessionária">Concession&aacute;ria</option>
    <option value="Construção Civil">Constru&ccedil;&atilde;o Civil</option>
    <option value="Consultoria">Consultoria</option>
    <option value="Corretora">Corretora</option>
    <option value="Educação">Educa&ccedil;&atilde;o</option>
    <option value="Eletrônica">Eletr&ocirc;nica</option>
    <option value="Energia">Energia</option>
    <option value="Engenharia">Engenharia</option>
    <option value="Entretenimento">Entretenimento</option>
    <option value="Equipamentos">Equipamentos</option>
    <option value="Expedição">Expedi&ccedil;&atilde;o</option>
    <option value="Finanças">Finan&ccedil;as</option>
    <option value="Governo">Governo</option>
    <option value="Hotelaria">Hotelaria</option>
    <option value="Imobiliário">Imobili&aacute;rio</option>
    <option value="Ind&uacute;stria">Ind&uacute;stria</option>
    <option value="ISP">ISP</option>
    <option value="Jogos/Games">Jogos/Games</option>
    <option value="Jurídico">Jur&iacute;dico</option>
    <option value="Livraria/Editora">Livraria/Editora</option>
    <option value="Manufatura">Manufatura</option>
    <option value="Meio ambiente">Meio ambiente</option>
    <option value="Mídia">M&iacute;dia</option>
    <option value="Outros">Outros</option>
    <option value="Produtos químicos">Produtos Qu&iacute;micos</option>
    <option value="Recreação">Recrea&ccedil;&atilde;o</option>
    <option value="Sa&uacute;de">Sa&uacute;de</option>
    <option value="Seguros">Seguros</option>
    <option value="Sem fins lucrativos">Sem fins lucrativos</option>
    <option value="Serviços">Servi&ccedil;os</option>
    <option value="Serviços p&uacute;blicos">Servi&ccedil;os p&uacute;blicos</option>
    <option value="Tecnologia">Tecnologia</option>
    <option value="Telecomunicações">Telecomunica&ccedil;&otilde;es</option>
    <option value="Transportes">Transportes</option>
    <option value="Turismo">Turismo</option>
    <option value="Varejo">Varejo</option>
    <option value="Vestuário">Vestu&aacute;rio</option>
    <option value="WebDesign">WebDesign</option>
    <option value="WebHosting">WebHosting</option>
    </select></td></tr>
    
    <tr><td>Nº de Atendentes:<br>(estimativa)</td><td bgcolor=red>&nbsp;</td><td><input  id="00N30000002PCb1" maxlength="25" name="00N30000002PCb1" size="20" type="text" class="required" /></td></tr>
    
    
    <tr><td>Vers&atilde;o:</td><td bgcolor=red>&nbsp;</td><td><input  id="00N30000002PCb8" maxlength="50" name="00N30000002PCb8" size="20" type="text" class="required" /></td></tr>
    
    <tr><td>Coment&aacute;rios:</td><td>&nbsp;</td><td><textarea  id="00N30000002PCb2" name="00N30000002PCb2" type="text" wrap="soft" rows="5"></textarea></td></tr>
    <tr><td>Protocolo de contato:</td><td bgcolor=red>&nbsp;</td><td><input id="00N30000002PCO8" maxlength="51" name="x00N30000002PCO8" size="20" type="text" /></td></tr>
    <tr><td colspan=3><br><input type="submit" name="submit" value="Requisitar Demo"></td></tr></table>
    </form>
    
    <script language="JavaScript" type="text/javascript">
    <!-- Begin
            pvName = unescape(params["site"]);               
              if (pvName) document.SalesForce.URL.value = pvName;            
    
            pvName = unescape(params["nome"]);               
              if (pvName) document.SalesForce.first_name.value = pvName;
    
            pvName = unescape(params["email"]);               
              if (pvName) document.SalesForce.email.value = pvName;
    
            pvName = unescape(params["telefone"]);               
              if (pvName) document.SalesForce.phone.value = pvName;
    
            pvName = unescape(params["empresa"]);               
              if (pvName) document.SalesForce.company.value = pvName;
    
            pvName = unescape(params["protocolo"]);               
              if (pvName) document.SalesForce.x00N30000002PCO8.value = pvName;            
          //  End -->
    
    </script>
    
    
    
    </body>
    </html>
    Thanks,
    OXY

  • #13
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by OXY View Post
    Hi,
    Thanks Philip M, I could not make it work , sorry, so I decided not to use Arty Effem's script and set the x manually on one field "name" hoping the "killx" function would do it's job but my CRM system is not receiving the info so I guess the "x" is not being removed. It recieves the info correctly when I don't use the script.

    I wonder if you could take a look at the whole thing and see if there is still any hope..
    killx needs to address the form elements; use it like this:
    Code:
    function killx(theForm)
    {
     for (var i=0, elems=theForm.elements; i < elems.length; i ++) 
      elems[i].name = elems[i].name.replace(/^x/, "");
    }
    and call it: onsubmit="killx(this)"

    Also just in case you're testing this page with no parameters, I would change
    var params = getParams(); to var params = getParams() || [];, which will prevent a script error and will show 'undefined' in the fields.

  • #14
    OXY
    OXY is offline
    New Coder
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Arty Effem View Post
    killx needs to address the form elements; use it like this:
    Code:
    function killx(theForm)
    {
     for (var i=0, elems=theForm.elements; i < elems.length; i ++) 
      elems[i].name = elems[i].name.replace(/^x/, "");
    }
    and call it: onsubmit="killx(this)"

    Also just in case you're testing this page with no parameters, I would change
    var params = getParams(); to var params = getParams() || [];, which will prevent a script error and will show 'undefined' in the fields.
    Hi Arty Effem, thanks for your comments. I did the modificaitons you suggested but unfortunatly I´m still not receiving the info in my CRM.
    I have simplified the form so it would just have the field with the variable the script should work on. Please see below:

    Code:
    <body>
    <head><title></title>
    
    <script language="JavaScript" type="text/javascript">
    function killx(theForm)
    {
     for (var i=0, elems=theForm.elements; i < elems.length; i ++) 
      elems[i].name = elems[i].name.replace(/^x/, "");
    }
    </script>
    
    <script language="JavaScript" type="text/javascript">
        
          <!-- Begin
    function getParams() {
      var idx = document.URL.indexOf('?');
      var tempParams = new Object();
      if (idx != -1) {
        var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
        for (var i=0; i<pairs.length; i++) {
          nameVal = pairs[i].split('=');
          tempParams[nameVal[0]] = nameVal[1];
        }
          return tempParams;
      }
    }
    var params = getParams();
    
            
          //  End -->            
    </script>
    
    </head>
    
    <body>
    
    <form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=ISO-8859-1" name=SalesForce method="POST" onsubmit="killx(this)">
    <input type=hidden name="oid" value="00D300000005zTX">
    <input type=hidden name="retURL" value="http://www.liveperson.com.br/confirma_demo.htm">
    
    <table cellpadding=0 cellspacing=4 border=0>
    <tr><td>
    Protocolo de contato:</td><td bgcolor=red>&nbsp;</td><td><input disabled id="00N30000002PCO8" maxlength="51" name="x00N30000002PCO8" size="20" type="text" />
    </td></tr>
    <tr><td colspan=3>
    <br><input type="submit" name="submit" value="Requisitar Demo">
    </td></tr>
    </table>
    </form>
    
    <script language="JavaScript" type="text/javascript">
    <!-- Begin
            pvName = unescape(params["protocolo"]);               
              if (pvName) document.SalesForce.x00N30000002PCO8.value = pvName;            
          //  End -->
    </script>
    </body>
    </html>
    Any help is appreciated,

    Thanks,

    OXY

  • #15
    Regular Coder ninnypants's Avatar
    Join Date
    Apr 2008
    Location
    Utah
    Posts
    504
    Thanks
    10
    Thanked 47 Times in 47 Posts
    I just thought of something are you required to have the 'name' and 'id' be the same value or could you edit one and have your CRM recognize it by the other?

    Or is it possible that you can write a function to change the name and id in some way but save the original to an array to be changed back right before submit?


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •