PDA

View Full Version : LoadVars variables


bladeMX
03-04-2004, 03:21 PM
When naming and giving values to defined variables with the LoadVars object are dashes forbidden?

Here is an example that works (no dash):
var obj = userComments;
obj.mailto = "mail";

This one does not (using dash):
var obj = userComments;
obj.mail-to = "mail";

How can I work around this? I can NOT change the 'mail-to' variables because it is already defined in the PERL script.

Any help?


:confused:

CyanBlue
03-04-2004, 03:36 PM
Try this...

obj["mail-to"] = "mail";

Let me know if it works or not... :)

bladeMX
03-04-2004, 03:51 PM
Write a book!!!

You are awesome CyanBlue!

Thank you for your time and efforts. It's greatly appreciated.

CyanBlue
03-04-2004, 10:53 PM
Just to let you know...

obj.mail-to gets translated as 'obj.mail - to' because of that minus sign... And, you might get into trouble later where you cannot really avoid that '-' sign with the solution that I have given you... So, it is best not to accept the variable name like that in the first place... Just my 2 cents... :)