Custom JSON string from form data

Hi,
I’ve been struggling with this concept for several days now and thought i’d give this a shot for some advice.

I’m using FusionCharts to plot some data based on a series of radio and checkbox selections. I want to re-render my chart each time a radio button changes. I know how to do that part. I’m getting stumped with building my JSON string to use in the chart.

Fusioncharts expects a variable containing a JSON object. It’s expecting a certain format though (key, value pairs). I know there are jQuery plugins that will get the values from a form and create a JSON object but like i said, there are arrays in this data and i dont think that parseJSON or JSONify does what i need.

I’m hoping to get some advice on how i might approach this.

thanks,
John

Maybe jQuery’s serializeArray could be what you’re looking for…
You will have to make your own array or object that contains the necessary data to send to FusionCharts and then serialize it.

I’ve tried jQuery SerializeArray. The big problem is that I’m just not very good as a programmer :frowning: I need the data from my form to come out looking like my chart needs. below is an excerpt from my working static chart data. There are are things in here that just aren’t in my form at all like "dataset, and “data,” or “value.” The “seriesname:…” is arbitrary and could be anything. The first “value” : “0” is going to be same for every data point. always starting with 0. So really what i need to come out of my form (on change) is the second value. I’m guessing i’ve got to find some way to insert these static values as i iterate through my form elements in the js but not really sure how.

-john

Format FusionCharts expects:

“dataset”:[
{
“seriesname”:“Set full retirment age to”,
“data”:[
{
“value”:“0”
},
{
“value”:“100”
}
]
},
{
“seriesname”:“Set payroll tax cap to”,
“data”:[
{
“value”:“0”
},
{
“value”:“130”
}
]
},