Passing Search variable in Hyperlink

Passing Search variable in Hyperlink

gerrypezgerrypez Posts: 2Questions: 0Answers: 0
edited August 2010 in General
Is it possible to pass a Search variable in a hyperlink?

For example: ?search=foo. I'm creating a table with php/mysql. I can $foo = $_GET['foo'] so I have the users search string. But now how do I get $foo into the search box?

Ideally I want 'foo' to show up in the Search form box affecting the search, but also allow the user to search the entire table with 'bar'. I could change the Query on the page, but that would not allow the users to do a Search for something other than foo at the page.

PS: I found the note about server-side function (http://datatables.net/examples/server_side/custom_vars.html). But I'm having trouble understanding from this how to manipulate the search variable.

Thanks,

Gerry

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    When you initialise DataTables:

    [code]
    $(document).ready( function() {
    $('#example').dataTable( {
    "oSearch": {"sSearch": "<?=$_GET['foo'];?>"}
    } );
    } )
    [/code]
    http://datatables.net/usage/options#oSearch

    Allan
  • gerrypezgerrypez Posts: 2Questions: 0Answers: 0
    This worked great!

    "oSearch": { "sSearch": "<?php echo $_GET['foo']; ?>" },

    Thank you!
  • sroecosroeco Posts: 4Questions: 0Answers: 0
    You guys are amazing!

    This worked phenomenally well!

    Thank you!
This discussion has been closed.