...

View Full Version : eval bug.. ?!?!? eval method not working properly



whisk
01-13-2003, 09:48 PM
can someone please explain to me why this eval statement:

eval("var sTime = frmTimesheet." + datesArray[x] + "-startTime.value;");

returns an error - Expected ';'

?????

I have looked at this 100 ways and just don't know what is going on.. the best I have come up with is that its something to do with [x] but why, I do not know!!!


help please.

thx.

whisk
01-13-2003, 10:11 PM
ok 2 things I didn't know...

first you can't have a value attribute starting with numbers.. in my example dateArray[x] is a string of numbers...

secondly you can't have '-' character in a value attribute..

I never realized that value's are very much like c variables.. can't believe it to me so long to figure out :(

jkd
01-13-2003, 10:38 PM
var sTime = frmTimesheet[datesArray[x] + '-startTime'].value;

whisk
01-13-2003, 10:47 PM
Originally posted by jkd
var sTime = frmTimesheet[datesArray[x] + '-startTime'].value;

na.. its fixed now.. didn't you read the second post??.. the way you have replied probably wont work either... anyways I changed:

eval("var sTime = frmTimesheet." + datesArray[x] + "-startTime.value;");

to this:

eval("var sTime = frmTimesheet.startTime_" + datesArray[x] + ".value;");

works fine now.. but thanks anyway. :D

jkd
01-13-2003, 11:34 PM
Originally posted by whisk
the way you have replied probably wont work either... anyways I changed:

You're going to call me wrong without even trying it? All properties in Javascript are also made available through a hash, which accepts string arguments. some-thing may not be a valid property name, but it is a perfectly fine string.

whisk
01-13-2003, 11:47 PM
Originally posted by jkd
You're going to call me wrong without even trying it? All properties in Javascript are also made available through a hash, which accepts string arguments. some-thing may not be a valid property name, but it is a perfectly fine string.

I said your probably wrong.. anywho.. I tried your method and it didn't work :P

jkd
01-14-2003, 12:28 AM
Originally posted by whisk
I said your probably wrong.. anywho.. I tried your method and it didn't work :P

It works fine. Obviously there is something else wrong with your code. You don't need to be rude you know, forums are a friendly setting.

whammy
01-14-2003, 01:07 AM
Originally posted by jkd
It works fine. Obviously there is something else wrong with your code.

That sounds frighteningly similar to the reply I gave to someone else a couple of days ago, that apparently *didn't* try my solution, and just assumed I was wrong because of a typo in a tutorial. ;)

whisk
01-14-2003, 01:10 AM
in the context of this thread I'm right and your wrong.. stop being such a super moderator :rolleyes:

jkd
01-14-2003, 03:09 AM
Originally posted by whisk
in the context of this thread I'm right and your wrong.. stop being such a super moderator :rolleyes:

... how old are you?

jkd
01-14-2003, 03:20 AM
Actually no. This thread is going to deteriorate. A solution has been presented, and you seem to have arrived at your own, so this thread has served its purpose.

PM me if you feel you must continue your immaturity.

In the mean time, this thread is closed.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum