Web Analytics Made Easy -
StatCounter Creating associative array - CodingForum

Announcement

Collapse
No announcement yet.

Creating associative array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating associative array

    I want to create an json associative array that I can pass to a php script via AJAX.

    The js script I've put together thus far, gathers the pertinent data, but I'm stuck on how to use that data to put together the json object. Below is what I've got so far. Help is appreciated.

    Code:
    var imgCaption = document.getElementsByName("imgCaption[]");
        for (var k = 0; k < imgCaption.length; k++){
        CaptionObj[imgCaption[k].id] = imgCaption[k].value
        }
    Last edited by Dan06; Apr 9, 2009, 04:01 PM.

  • #2
    http://www.json.org/json2.js

    Download that and use the object stringify function. That'll convert any JS value into valid JSON.
    Feel free to e-mail me if I forget to respond ;)
    [email protected]

    Comment

    Working...
    X