how to clear search input with button

how to clear search input with button

Jarod511Jarod511 Posts: 8Questions: 0Answers: 0
edited December 2011 in General
Hey there,

I would like to clear the search input field when I click on a button but I don't find the id or the name of this search input. Could you tell what is the name or the id of this Search input field, please ?

[code]

[/code]

Replies

  • John ArcherJohn Archer Posts: 56Questions: 1Answers: 0
    Hi!

    I am not sure, what you mean ... The name of your input field is "begin".

    I do it this way: for every column I generate a input field with PHP with an unique id, e.g. id="search". $i, where $i is a PHP var, that is incremented. When I click on a button, basically I do the same things on the specific input element like Allan does in the blur function (have a look here, e.g.: http://www.datatables.net/release-datatables/examples/api/multi_filter.html). After that I do am calling fnFilter with an empty search term.

    Hope it helps.

    Regards
  • Jarod511Jarod511 Posts: 8Questions: 0Answers: 0
    Hi John,
    Thanks for your reply. Actually, it's the search field of the datatable that I want to clear before to submit. Indeed, if an user forgot to clear the search field of the datatable, it will take only the last one which has been selected. That's why I would like to clear it but I don't know how to do it.

    Regards,
    Jarod.
  • John ArcherJohn Archer Posts: 56Questions: 1Answers: 0
    Just to make sure, I understand you correctly: Do you mean the global search box or the individual column filter boxes for each column?
  • Jarod511Jarod511 Posts: 8Questions: 0Answers: 0
    John,
    I mean the global search box at the right top of the datatable.
  • John ArcherJohn Archer Posts: 56Questions: 1Answers: 0
    Ok. Just look for the css class ".dataTables_filter". E.g. I use

    [code]var dataTableFilter = find(".dataTables_filter");[/code]

    then find the input field inside of dataTableFilter and then add a custom ID with

    [code]find("input").attr("id", "globalSearchField")[/code]

    With that I can easily alter my input field (later or immediately) .
This discussion has been closed.