Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Help with escape characters

Reply
Thread Tools

Help with escape characters

 
 
john
Guest
Posts: n/a
 
      06-24-2004
I am using Morten's JavaScript Tree Menu http://www.treemenu.com and i need
to be able to put a node into the tree which is called

'second level -23'

which comes from a database

The code goes like so

var second_level_-23 = null;
second_level_-23 = new MTMenu();
second_level_-23.addItem('second level - 23'..........

I need to do something to the - in the middle of the string. Can anyone
tell me how to convert 'second level -23' to a legal name for a javascript
var. I am building the tree dynamically so need to write the replacement
string in VB to pass to the completed script.

Many thanks

John



 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      06-24-2004


john wrote:


> var second_level_-23 = null;
> second_level_-23 = new MTMenu();
> second_level_-23.addItem('second level - 23'..........


If that is a global variable then do
window['second_level-23'] = new MTMenu();
window['second_level-23'].addItem('second level - 23'..........
Otherwise use an object e.g.
var levels = {};
levels['second_level-23'] = new MTMenu();
levels['second_level-23'].addItem('second level - 23'..........

--

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read strings cantaining escape character from a file and useit as escape sequences? slomo Python 5 12-02-2007 11:39 AM
Re: html special character and escape characters knowledgepays@hotmail.com ASP .Net 0 01-27-2005 02:08 AM
trying out escape characters Griff Perl 6 08-20-2004 08:20 PM
What Happens To Escape Characters? Guadala Harry ASP .Net 3 08-19-2004 01:59 AM
Escape characters Maziar Aflatoun ASP .Net 3 12-05-2003 05:55 PM



Advertisments