[jQuery] Re: help with array for flot
aquaone thank you! I need to do a little reading up on what .push does rolf On Jun 5, 2008, at 3:09 PM, aquaone wrote: $('#plot').click(function() { var d1 = []; $('#curveData tbody tr').each(function() { tr = $(this); pair = []; tr.find('input.qty').val() && tr.find('input.price').val() && pair.push( tr.find('input.qty').val(), tr.find('input.price').val () ) && d1.push( pair ); }); $.plot($("#graphHolder"), [ { color: "#bb", data: d1, points: { show: true }, lines: { show: true } } ]); });
[jQuery] Re: help with array for flot
$('#plot').click(function() { var d1 = []; $('#curveData tbody tr').each(function() { tr = $(this); pair = []; tr.find('input.qty').val() && tr.find('input.price').val() && pair.push( tr.find('input.qty').val(), tr.find('input.price').val() ) && d1.push( pair ); }); $.plot($("#graphHolder"), [ { color: "#bb", data: d1, points: { show: true }, lines: { show: true } } ]); });
[jQuery] Re: help with array for flot
cool - that's part of what I need. Since I'm actually using inputs in the td's, wouldn't I need to get the value of the input within each td? maybe I can figure that out from here... (there's actually a plugin that converts tables to flot graphs... but since I'm using inputs in a table, I figured it wouldn't work) thanks, rolf On Jun 4, 2008, at 7:39 PM, Leanan wrote: This is kinda pseudocodish, but it should do what you want: $('button selector').click(function() { $('table tr').each(function() { x = $(this + 'td:eq(1)'); //should grab the second td y = $(this + 'td:eq(2)'); //should grab the third td push(array,[x,y]); }); }); Of course if you have multiple tables you'll be iterating over all of them, so you may need to an id to the table so that you can use that to select the proper table.
[jQuery] Re: help with array for flot
This is kinda pseudocodish, but it should do what you want: $('button selector').click(function() { $('table tr').each(function() { x = $(this + 'td:eq(1)'); //should grab the second td y = $(this + 'td:eq(2)'); //should grab the third td push(array,[x,y]); }); }); Of course if you have multiple tables you'll be iterating over all of them, so you may need to an id to the table so that you can use that to select the proper table.