junkmail
05-06-2003, 09:16 PM
Hey,
Can anyone please tell me that if there is a way to rename a variable? for example
function DisplayMsg(message)
{
var message1 = "Hello";
var message2 = "World";
// Is there a way that computer will display message 1 by changing the variable name message to message+'the number'
alert(message)
// I know I can use if else or switch statements but I do not want to use that... is there another way?
}
<a href="#" onclick="DisplayMsg('1')">Go</a>
I would appretiate any help....
Thanks....:rolleyes:
Can anyone please tell me that if there is a way to rename a variable? for example
function DisplayMsg(message)
{
var message1 = "Hello";
var message2 = "World";
// Is there a way that computer will display message 1 by changing the variable name message to message+'the number'
alert(message)
// I know I can use if else or switch statements but I do not want to use that... is there another way?
}
<a href="#" onclick="DisplayMsg('1')">Go</a>
I would appretiate any help....
Thanks....:rolleyes: