arrays - Combining two object in javascript and convert to String -


I hope that I am clarifying something here, but I try to set two variables for the last half day I have a certain format in javascript that I can do as a string, though I need it in a different format.

If I select the option from the check box {"GILLS": "7"}, works fine but if two options are selected then query1 < / Code> should look like [{"GILLS": "1"}, {"GILLS": "7"} . I can not use extreme = + because it removes an unexpected token error.

  var Query1 = ''; Var query3 = ''; If ($ ('input [name = checkbox2a]: check'). Length> 0) {var Query3 = {"Gills": "7"}; } If ($ ('input [name = checkbox2b]: checked'). Length> gt; {var query3 = {"gilus": "1"}; }  

Try

  var query1 = [ ];  

and use your function

  Query1.push ({"gilus": "1"})  

The change will be like the following

  var Query1 = []; Var query3 = []; If ($ ('input [name = checkbox2a]: check'). Length> 0) {Query3.push ({"Gillus": "7"}); } If ($ ('input [name = checkbox2b]: check'). Length & gt; 0) {Query3.push ({"Gillus": "1"}); }  

Then you can enter the string to join

  Query3.join (",")  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -