Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-09-2009, 07:27 PM   PM User | #1
Dan06
Regular Coder

 
Join Date: Sep 2008
Posts: 205
Thanks: 1
Thanked 0 Times in 0 Posts
Dan06 is an unknown quantity at this point
Question 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; 04-09-2009 at 09:01 PM..
Dan06 is offline   Reply With Quote
Old 04-09-2009, 09:17 PM   PM User | #2
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
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 ;)
ohsosexybrit@gmail.com
itsallkizza is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:21 AM.


Advertisement
Log in to turn off these ads.