...

View Full Version : Variables starting with numbers - Workaround?



OXY
08-02-2008, 03:31 AM
Hi I have found the script below on this forum (http://www.codingforums.com/showthread.php?t=104796#goto_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.


<!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.



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/web_to_lead/demo_request.htm?site=www.site.com.br&nome=OXY&telefone=1234567890&empresa=company&protocolo=LTK123456789X&email=mail@host.com

A really appreciate any help/reply :thumbsup:

Best Regards,
OXY

ninnypants
08-02-2008, 07:54 AM
I don't really understand what you want. because your can store variables that start with numbers


var yourVar = '00N30000002PCO8';

or you can make calls on these id's or name's as numbers


document.getElementById('00N30000002PCO8')

Philip M
08-02-2008, 08:48 AM
I don't really understand what you want. because your can store variables that start with numbers


var yourVar = '00N30000002PCO8';

or you can make calls on these id's or name's as numbers


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

Arty Effem
08-02-2008, 11:32 AM
for (var i=0; i<pairs.length; i++) {
nameVal = pairs[i].split('=');
tempParams[nameVal[0]] = nameVal[1];
}
If you change the above to this:

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.

Philip M
08-02-2008, 12:27 PM
If you change the above to this:

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.

OXY
08-02-2008, 03:18 PM
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.:thumbsup:




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



Here is the whole code I´m using:

<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>

Philip M
08-02-2008, 05:07 PM
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.

OXY
08-02-2008, 05:52 PM
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,:thumbsup:

OXY

Philip M
08-02-2008, 06:11 PM
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.

OXY
08-02-2008, 11:27 PM
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

Philip M
08-03-2008, 09:03 AM
Something like:-


<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/, "");
}
}
}

OXY
08-04-2008, 07:04 AM
Something like:-


<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..


<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

Arty Effem
08-04-2008, 01:53 PM
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:
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.

OXY
08-05-2008, 05:44 AM
killx needs to address the form elements; use it like this:
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:


<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

ninnypants
08-05-2008, 10:06 PM
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?

Arty Effem
08-06-2008, 01:12 AM
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.You need to verify that the correct data is being posted. One way is to change the form's method to 'get' and watch/save the parameters displayed in the querystring. Alternatively you could post the form to another page that displays the received data.
If the data is correct, then it's not a JS issue.

OXY
08-07-2008, 12:08 AM
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?

Hi ninnypants, thanks for your comments. On my tests I have noticed that the CRM system somehow compares the "ID" tag with the "Name" tag so I believe it´s not possible to have one different from another.

As for your second suggestion, we are trying to do somenthing similar. I´m manually adding the letter "x" to the "Name" variable (which starts with a number) and we are trying to remove the "x" from the "Name" variable when the form is submitted.

Since I´m not a coder I´m not sure I have implemented the codes corretly, that´s why my former posts have the whole code I´m using.

Thanks,
OXY

OXY
08-07-2008, 12:09 AM
You need to verify that the correct data is being posted. One way is to change the form's method to 'get' and watch/save the parameters displayed in the querystring. Alternatively you could post the form to another page that displays the received data.
If the data is correct, then it's not a JS issue.

Thanks Arty Effem, I was wondering how I could do that. I will try to do it and let you know,

Best Regards,

OXY

OXY
08-08-2008, 06:34 AM
Originally Posted by Arty Effem View Post
You need to verify that the correct data is being posted. One way is to change the form's method to 'get' and watch/save the parameters displayed in the querystring. Alternatively you could post the form to another page that displays the received data.
If the data is correct, then it's not a JS issue.

Hi Arty Effem, I would like to thank you. I have tested the form and your "killx" function works fine. The form field I was testing is pre populated by a ticket number the visitor is not supposed to edit so it had the attribute "disabled" to prevent the vistor to edit it. What I wasn´t aware of is that this attribute also prevent the data to be submitted.

So now I just have to find out another way to prevent the visitors to edit the field but that´s another story :)

I also would like to thank all others who contributed.

OXY



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum