Advertisement
Guest User

Untitled

a guest
Jul 31st, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. Why is Javascript object not updating fields?
  2. var imageType = "BoxArt";
  3. var uploadReason = "New season";
  4. var fileKey = "b2fc";
  5.  
  6. alert("imageType = " + imageType);
  7. alert("uploadReason = " + uploadReason);
  8. alert("fileKey = " + fileKey);
  9.  
  10. var iVO = { "images":{}};
  11. var thisImage = fileKey;
  12. iVO["images"][thisImage.fileKey] = thisImage;
  13. iVO["images"][thisImage.imageType] = imageType;
  14. iVO["images"][thisImage.uploadReason] = uploadReason;
  15.  
  16. alert("iVO['images'][thisImage.imageType] = " + iVO["images"][thisImage.imageType]);
  17. alert("iVO['images'][thisImage.uploadReason] = " + iVO["images"] [thisImage.uploadReason]);
  18. alert("iVO['images'][thisImage.fileKey] = " + iVO["images"][thisImage.fileKey]);
  19. alert("JSON.stringify(iVO):n" + JSON.stringify(iVO));
  20.  
  21. imageType = "BoxArt"
  22. uploadReason = "New season"
  23. fileKey = "b2fc"
  24. iVO['images'][thisImage.imageType] = "New season"
  25. iVO['images'][thisImage.uploadReason] = "New season"
  26. iVO['images'][thisImage.fileKey] = "New season"
  27. JSON.stringify(iVO):
  28. {"images"}:{"undefined":"New season"}}
  29.  
  30. {
  31. "images":
  32. {
  33. "b2fc":
  34. {
  35. "imageType":"BoxArt",
  36. "uploadReason":"New season",
  37. "fileKey":"b2fc"
  38. }
  39. }
  40. }
  41.  
  42. iVO["images"][thisImage.fileKey] = thisImage;
  43. iVO["images"][thisImage.imageType] = imageType;
  44. iVO["images"][thisImage.uploadReason] = uploadReason;
  45.  
  46. iVO['images'][thisImage] = {
  47. "imageType":"BoxArt",
  48. "uploadReason":"New season",
  49. "fileKey":"b2fc"
  50. };
  51.  
  52. iVO.images[thisImage] = {
  53. "imageType":"BoxArt",
  54. "uploadReason":"New season",
  55. "fileKey":"b2fc"
  56. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement