Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi, I have problem to get value on textbox with jquery. here my script

PHP
<input autocomplete='off' id='filter' name='filterpenulis' type='text' value=''  önkeyup="var url='filter.php?key='+document.getElementById('filter').value; $('#showpenulis').load(url);  return false;">
<div id='showpenulis'></div>

and here my filter.php
PHP
<?php
   $key=$_GET['key'];
   echo $key;
   .......
?>


this script above not work if I input "Space Bar".
example
input => "qwerty"
result=> "qwerty"

input => "qwerty qwerty"
result=> "" <= blank output

how to get result "qwerty qwerty"?
Posted
Comments
Er. Tushar Srivastava 17-Dec-13 9:36am    
Have you tried using urldecode($_GET['key']); ... Try it... It will solve the problem

Hi Friend,

I have solved the Problem...
Here's the solution. DO Mark it as solved :)

HTML
<input autocomplete='off' id='filter' name='filterpenulis' type='text' value=''  önkeyup="var url='filter.php?key='+encodeURIComponent(document.getElementById('filter').value); $('#showpenulis').load(url);  return false;">
<div id="showpenulis"></div>


And the PHP File.
PHP
echo urldecode($_GET['key']);


The Problem was that the URL was not encoded thereby the issues. I encoded the URI using jQuery's encodeURIComponent() function and then decoding it in filter.php using PHP's urldecode() function.

Hope that it will help you...

With Regards
Tushar Srivastava
 
Share this answer
 
Comments
bagus bujangga 17-Dec-13 13:28pm    
Thanks.
Could you just use double-quotes on your value="..."

$key=$_GET['key']; ====> $key=$_GET["key"];
 
Share this answer
 
Comments
bagus bujangga 16-Dec-13 7:31am    
Hi, thanks for try help me, but not work.
I thing the problem in
onkeyup="var url='filter.php?key='+document.getElementById('filter').value; $('#showpenulis').load(url); return false;
Vivekh RF 16-Dec-13 7:46am    
i think u are missing double quotes after
onkeyup="var url='filter.php?key='+document.getElementById('filter').value'"
i mean url in single quotes and after that close double quotes

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900