...

View Full Version : Creating associative array



Dan06
04-09-2009, 07:27 PM
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.



var imgCaption = document.getElementsByName("imgCaption[]");
for (var k = 0; k < imgCaption.length; k++){
CaptionObj[imgCaption[k].id] = imgCaption[k].value
}

itsallkizza
04-09-2009, 09:17 PM
http://www.json.org/json2.js

Download that and use the object stringify function. That'll convert any JS value into valid JSON.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum