Thanks Kanpan, with your code I know where to make the ajax call. Combining with MorningZ's solution and your suggestion I am very certain that I will be able to get my task done!
Thank you guys for your help! On Jan 4, 11:55 pm, Kanpan <statler.da...@gmail.com> wrote: > What you know is that you're assigning classes to the selected cells. > Your best bet is to detect an onclick event on your button and then > loop through the td elements with the class "sel" and get each of > their value. Then take those values and submit them via ajax to your > php script. > > Something like... > > $("#MyBtn").click(function() { > var values; > $(".sel").each(function() { > values += $(this).html()+","; > }): > $.ajax({ > ... > }); > > }); > > On Jan 4, 10:11 pm, MT <matt.tha...@gmail.com> wrote: > > > Hi all, > > > I am new to jQuery and I would like to process a matrix operation > > using PHP. > > The front-end code is done bellow, its a 3x3 table. the user could > > select/deselect individual cells of the table and click the button > > that calls a PHP script that will run some function. > > > 1) How do I know if a cell is selected? Is there is is_selected( ) > > function in jQuery? > > 2) Would it be possible to send a 3x3 array to my PHP script? > > > Please provide me with any info on this. Thanks! > > > MT > > > My current test code. > > --------------------------------------------------------------------------- > > ------------------------------------- > > <html><head><title>Test</title> > > <script type='text/javascript' > > src='http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js'></ > > script> > > > <script type="text/javascript"> > > $(document).ready(function() { > > $("td").toggle( > > function () { $(this).addClass("sel"); }, > > function () { $(this).removeClass("sel"); } > > ); > > > }); > > > </script> > > <style> > > .sel { background-color:red; } > > </style> > > > </head><body> > > > <table border="5" cellspace=10> > > <tr><td>1</td><td>2</td><td>3</td></tr> > > <tr><td>4</td><td>5</td><td>6</td></tr> > > <tr><td>7</td><td>8</td><td>9</td></tr> > > </table> > > > <button>Click here to process the selection with a php script</button> > > > </body></html> > > --------------------------------------------------------------------------- > > -------------------------------------