2 Replies - 6547 Views - Last Post: 14 August 2011 - 02:45 PM

#1 hockey97   User is offline

  • D.I.C Regular

Reputation: -77
  • View blog
  • Posts: 300
  • Joined: 25-September 08

why is this giving me an unexpected number error ?

Posted 14 August 2011 - 03:28 AM

Hi, I am trying to generate an array but I am getting an unexpected number error via firebug.

here is the code:
var make2 = $('input[name="delete[]"]:checked').val();
var make 3 = make2;
var mantern = [] ;
while ( make3 > 0 ){
var mantern[make3] = $('input[name="delete[]"]:checked').val();
make3--;
}


why is this happening. When I tried the above code and posted it via firebug it gives me output of unexpected number.

I don't understand why it's outputting that?

Is This A Good Question/Topic? 0
  • +

Replies To: why is this giving me an unexpected number error ?

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6260
  • View blog
  • Posts: 24,030
  • Joined: 23-August 08

Re: why is this giving me an unexpected number error ?

Posted 14 August 2011 - 05:27 AM

var make 3 = make2;

Has Javascript suddenly started allowing spaces in variable names?
Was This Post Helpful? 0
  • +
  • -

#3 hockey97   User is offline

  • D.I.C Regular

Reputation: -77
  • View blog
  • Posts: 300
  • Joined: 25-September 08

Re: why is this giving me an unexpected number error ?

Posted 14 August 2011 - 02:45 PM

View PostJackOfAllTrades, on 14 August 2011 - 06:27 AM, said:

var make 3 = make2;

Has Javascript suddenly started allowing spaces in variable names?



no that wasn't the problem. There is no space in the real code. For some reason when I type it here there was a space created.

the problem was this var mantern[make3] = I used var so it was creating a new variable instead of using the variable already created that has an array stored in it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1