Mystry characters,

S

Satya

Hi

I have a field called method, which has values like
App,BCC,DED

using the below function im trying to delimit with ":", so the values
should be like
"App","BCC","DED"

but the sLookupKey has a value like:
App":"BCC":"DED":"

2 issues are above, the first " is missing
the last it adds up with :" again for value that is not available

var sFieldVal = trim(document.forms[0].Method.value);
var sFieldValArray = null;
var sLookupKey = "";

if ( sFieldVal.indexOf(",") != -1 )
{
sFieldValArray = sFieldVal.split(",");
for (n=0; n<sFieldValArray.length; n++)
{
sLookupKey += (sFieldValArray[n]+'":"');
}
}
else
{
sLookupKey = sFieldVal;
}

can you pls. help
Sathya
 
R

Randy Webb

Satya said the following on 3/16/2006 7:08 AM:
Hi

I have a field called method, which has values like
App,BCC,DED

using the below function im trying to delimit with ":", so the values
should be like
"App","BCC","DED"

but the sLookupKey has a value like:
App":"BCC":"DED":"

2 issues are above, the first " is missing
the last it adds up with :" again for value that is not available

var sFieldVal = trim(document.forms[0].Method.value);
var sFieldValArray = null;
var sLookupKey = "";

sLookupKey = "\"";
if ( sFieldVal.indexOf(",") != -1 )
{
sFieldValArray = sFieldVal.split(",");
for (n=0; n<sFieldValArray.length; n++)
{
sLookupKey += (sFieldValArray[n]+'":"');
}

sLookupKey = sLookupKey.substring(0,sLookupKey.length-2);

That is it at it's simplest. There are other ways.
Add the leading " and then strip the trailing :" that you don't want.

And please don't use tabs in posted code, use single or double spaces
per tab.
 
T

Thomas 'PointedEars' Lahn

Satya said:
I have a field called method, which has values like
App,BCC,DED

using the below function im trying to delimit with ":", so the values
should be like
"App","BCC","DED"

but the sLookupKey has a value like:
App":"BCC":"DED":"

2 issues are above, the first " is missing
the last it adds up with :" again for value that is not available

Please learn to debug (your) code. There are a number of acceptable
script debuggers out there, and you can also use the window.alert()
method for debugging. said:
Code:
[/QUOTE]

Your indentation is awkward, to say the least.  You make it look like
as if the rest of the code would be part of the assigned value of
`sFieldVal'.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top