When click on button redirect to new page but POST variable from selected row(s) in table

When click on button redirect to new page but POST variable from selected row(s) in table

brisc101brisc101 Posts: 3Questions: 0Answers: 0
edited July 2013 in TableTools
First off, this is a great tool. Great support for this tool as well.
I've been looking on the forums and I can't quite seem to find what I am trying to do. I've always worked in php, but not great at JS.

I created a "Edit device" button, and when it's clicked I want to redirect to another page (manage.php) and I want to pass data to that manage.php with the contents of only the selected rows from the table. I just need the first column to be passed (Model).

Basically I want the Edit button to do this

Replies

  • brisc101brisc101 Posts: 3Questions: 0Answers: 0
    I've found that I can use fnClick, but I'm not sure how to compile the selected rows only and post the data to manage.php.

    [code]
    "fnClick" : function (nButton, oConfig, flash) {
    // Is there a better way to do this?
    // window.location.replace("manage.php?id="??);
    }
    [/code]

    Anyone have any ideas?
    Thanks!
  • brisc101brisc101 Posts: 3Questions: 0Answers: 0
    Thought I would post my code, works great for me. This passes all selected rows (sData) seperated by a comma and opens manage.php

    [code]
    "fnClick": function ( nButton, oConfig ) {
    var oTT = TableTools.fnGetInstance( 'example' );
    var sData = oTT.fnGetSelectedData();

    if (sData.length = 1) {
    window.location.href = "manage.php?search="+ sData;
    return false;
    }
    }

    [/code]

    Depending on how many rows you have selected, sData is pretty big. I ended up parsing the data that I needed in manage.php as I couldn't figure out how to just pass the first column (Model) only to manage.php
  • balnysbalnys Posts: 10Questions: 1Answers: 0
    Hi,

    Thanks for posting.

    Same problem here. Though I want to transfer data through POST method by .ajax()..

    Any guidance on this question are welcome. :-)
  • allanallan Posts: 63,678Questions: 1Answers: 10,498 Site admin
    So when you click on a button, you want to send an Ajax request? You would override the fnClick function for the button ( `{ sExtend: 'div', fnClick: function ( button, conf ) { ... } );` ) and put your Ajax call inside the fnClick handler.

    Allan
  • majik27majik27 Posts: 4Questions: 0Answers: 0
    I just want to ask what code do we need to write in the phpfile (in this case manage.php) to get the data.

    Thanks
This discussion has been closed.