Filter from $_GET
Filter from $_GET
Hey, I'm working on a site with a typical datatable on a secondary site.
I would like for my users to be able to type in a string on the frontpage, press enter, and then be directed to my datatable-site, where the string they typed will then be the filter for the datatable.
I'm no javascript-shark, so this might be a silly question :)
I would like for my users to be able to type in a string on the frontpage, press enter, and then be directed to my datatable-site, where the string they typed will then be the filter for the datatable.
I'm no javascript-shark, so this might be a silly question :)
This discussion has been closed.
Replies
maybe something like this can help:
[code]
$(document).ready(function() {
$('#example').dataTable({
"fnInitComplete": function() {
$(".top input:first").text("<? echo $_GET['your_string']?>").focus();
}
});
});
[/code]
Regards
achlan
Here I'm just trying the idea out with some random value:
[code]
$(document).ready(function() {
$('#example').dataTable({
"fnInitComplete": function() {
$("input:first").text("test").focus();
}
});
});
[/code]
That puts the field in focus, but leaves the value empty.
I'm pretty sure this is just a pretty basic javascript mistake, but as I said, I'm not too familiar with it :)
Any suggestions?
[code]text("test")[/code]
with
[code]val("test")[/code]
Which leads me to my next question:
How do I make it run the search?
(as it is now, it just has the default value "test", but lacks the user-input "enter")
[code]
$(document).ready(function() {
$('#example').dataTable({
"fnInitComplete": function() {
$("input:first").val("test").keyup().focus();
}
});
});
[/code]
I finally got it to work perfectly from a post input field.
Thank you SO much for helping me out Achlan! :D