Forum Moderators: open

Message Too Old, No Replies

calling .match twice gives error

the good ol' "Object doesn’t support this property or method"

         

webgambit

4:15 pm on Feb 26, 2009 (gmt 0)

10+ Year Member



I'm trying to find the right balance here of not going too long winded but not being too vague. If I stray in either direction, please let me know.

I have to take a string which has a time in it in 24 hour format, change the time to 12 hour format and output it to the page. Unfortunately due to the particulars of this situation, I'm limited mostly to JavaScript.

Here's an example of what the text could look like:
1 - Date:2/28/2009, Time:0900-1200, Type:BRK, Comment:bla bla 2 - Date:3/05/2009, Time:1100-1400, Type:PUB, Comment: yada yada

I have a javascript class that works in FF but in IE7. In IE it gives the 'Object doesn’t support this property or method'. Here's the line it references and the one above it for context.


for( var key in times ) {
original_hour = times[key].substring( 0, 2 );

The time variable is an array, at this point in the script it would have 4 values in it, based on the example string.

If anyone could help me figure out what's causing IE to balk at this script I would really appreciate it.

Rambo Tribble

9:57 pm on Feb 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For/in is usually used to retrieve name/value pairs that are an object's properties. I think you just want a simple "for" loop here.

webgambit

11:03 pm on Feb 26, 2009 (gmt 0)

10+ Year Member



Thanks Rambo, I'll give that a go and see what happens.

Also, sorry for the misleading subject line. This post was literally the last thing I did prior to leaving for an outpatient surgery this morning so my mind wasn't fulling on task.

Rambo Tribble

1:25 am on Feb 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I hope things went well for you with the op and that this solves your problem, as well.