manix Posted July 9, 2011 Share Posted July 9, 2011 Heya, I'm trying to create an input field that's supposed to redirect me to a page, with a variable the value of the input, when I press enter, but I'm failing.. <input id="search" type="text" value=" search .." onkeypress="if(window.event && window.event.keyCode == 13) {window.location = 'blank.php?search='+document.getElementById('search').value;}" /> Link to comment https://forums.phpfreaks.com/topic/241539-detect-return-and-redirect/ Share on other sites More sharing options...
Eman_321 Posted July 10, 2011 Share Posted July 10, 2011 write a function and just call that function, try onkeydown instead of onkeypress Link to comment https://forums.phpfreaks.com/topic/241539-detect-return-and-redirect/#findComment-1240973 Share on other sites More sharing options...
manix Posted July 12, 2011 Author Share Posted July 12, 2011 Ermm Okay.. What I now have is this <script type="javascript"> fsearch(){ if (event.keyCode==13){ window.location = "blank.php?search="+document.getElementById('search').value; } } </script> <input id="search" type="text" value=" Search .." onkeydown="fsearch()"/> but it's still not redirecting me, it's just reloading the current page :s Link to comment https://forums.phpfreaks.com/topic/241539-detect-return-and-redirect/#findComment-1241823 Share on other sites More sharing options...
manix Posted July 14, 2011 Author Share Posted July 14, 2011 ~bump .. anyone ? Link to comment https://forums.phpfreaks.com/topic/241539-detect-return-and-redirect/#findComment-1242610 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.