It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

hit unknown error

hit unknown error

Postby hhheng on Wed Dec 26, 2007 9:49 am

I had hit by one error in javascript.

I got 5 data which is 326195,A00148,A004\592. When i click on A004\592 the data will automatically change to A004|592. May i know wat the meaning for the "\" in javascript?
hhheng
 
Posts: 4
Joined: Wed Dec 26, 2007 1:30 am

Re: hit unknown error

Postby leonard on Wed Dec 26, 2007 3:13 pm

hhheng wrote:I got 5 data which is 326195,A00148,A004\592.
No idea what you are talking about.

hhheng wrote:May i know wat the meaning for the "" in javascript?
The backslash '\' is normally used to write a String on multiple lines:

Code: Select all
alert('this will work');

Code: Select all
alert('this will
NOT work');

Code: Select all
alert('this however \
will work again');


cheers
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

Postby hhheng on Thu Dec 27, 2007 1:28 am

hello leonard
I had try the solution you give me. The \ actually is like a space that can separate two sentences. My question is when i onclick the data which is A004\592. The data will auto change to A004|592 when this data pass through javascript. May I know what the problem I facing now?
hhheng
 
Posts: 4
Joined: Wed Dec 26, 2007 1:30 am

Postby leonard on Thu Dec 27, 2007 6:40 am

The description of your problem is too vague.

Please post the code here or give us a link to your problem.

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

Postby hhheng on Thu Dec 27, 2007 8:11 am

errr. The data i retrieve from database is A004\592. When i choose this data from the table. the data appear as A004|592 . thus my another related become undefined value. Because ' \ ' have a meaning in javascript. my data become undefined value. If i change the data as A004/592 then the data is normal. Sorry i don have image for u.
hhheng
 
Posts: 4
Joined: Wed Dec 26, 2007 1:30 am

Postby leonard on Thu Dec 27, 2007 9:11 am

the most easy solution would probably be:
modify your database select-statement so that you replace '\' with '\\'

Your data will then be 'A004\\592' and will be displayed as 'A004\592'

cheers!
- leonard
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

Postby leonard on Thu Dec 27, 2007 9:16 am

the escape codes for a String in JavaScript are:

\b Backspace
\& Ampersand
\f Formfeed
\n New Line
\r Carriage Return
\t Tabulator
\' single quote
\" double quote
\\ Backslash

aparently \5 is somehow substituted by |
Last edited by leonard on Thu Dec 27, 2007 9:25 am, edited 2 times in total.
:%s/^M//
There are 10 kinds of people:
Those who understand binary and those who don't.
User avatar
leonard
100+ Club
 
Posts: 147
Joined: Tue Dec 18, 2007 7:11 am
Location: Switzerland

Postby hhheng on Thu Dec 27, 2007 9:22 am

Your data will then be 'A004\\592' and will be displayed as 'A004\592'

I already try this method. But still facing the same error.

Anyways thanks. I still looking for solution.
hhheng
 
Posts: 4
Joined: Wed Dec 26, 2007 1:30 am


Who is online

Users browsing this forum: No registered users and 9 guests