0

I have a syntax error, in my code everything seems to be right but once I go to the console, I have the following error: SyntaxError: missing : after property id

I do not get what id because I do not have any id on the lines of code I am working with.

This is my code:

wizard.place.phones = [];
 var phones = $('input[name="place[phones]"]');     
 var phoneLabels = $('input[name="place[phoneLabel]"]');
  for (var i = phones.length - 1; i >= 0; i--) {
    wizard.place.phones.push({$(phoneLabels[i]).val(): $(phones[i]).val().trim().replace(/\s+/g, ''),"description": ''});
      };
      if (wizard.currentIsValid){
         wizard.place.save();
      }
    }

and according to the console the error is on this line:

wizard.place.phones.push({$(phoneLabels[i]).val(): $(phones[i]).val().trim().replace(/\s+/g, ''),"description": ''});

Thanks in advanced.

  • You can't use `$(phoneLabels[i]).val()` as property name. – Felix Kling Oct 20 '14 at 23:36
  • You can't have dynamic property names in object definitions. In order to create a property dynamically, use `objectname[dynamicvaluegoeshere] = somevalue`. – Daedalus Oct 20 '14 at 23:36
  • @Daedalus ok but can you give me an example according to my code? I did not get you very well, sorry but I am new on this. – Marcelo Retana Oct 20 '14 at 23:51
  • @MarceloRetana Read the linked duplicate; your question has been closed, so it is impossible for me to answer. – Daedalus Oct 20 '14 at 23:54

0 Answers0