473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Mystry characters,

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

Mar 16 '06 #1
2 1071
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 16 '06 #2
Satya wrote:
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. <URL:http://jibbering.com/faq/>
[code]


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
Mar 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Pikkel | last post by:
i'm looking for a way to replace special characters with characters without accents, cedilles, etc.
43
by: Vladimir | last post by:
Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2. Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4. But why that? Look: /* Each Unicode character...
4
by: wob | last post by:
Many thanks for those who responded to my question of "putting greek char into C string". In searching for an solution, I noticed that there are more than one version of "Extended ASCII...
35
by: Vladimir | last post by:
Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2. Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4. But why that? Look: /* Each Unicode character...
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.