My code is as follows:
<html>
<input type="datetime" name="datepicker" id="datepicker" />
<P id=firstp></P>
<button id="button" onClick="test_function();" type="button">View</button>
<script type="text/javascript">
function test_function(){
$("#firstp").load("view_calls_sort.inc.php?datepicker="+ $("#datepicker").val());}
</script>
</html>
view_calls_sort.inc.php:
$datepicker=$_GET['datepicker'];
echo $datepicker;
im trying to get the datepicker value to view_calls_sort.inc.php, Above code doesn't seem to work,as an example when I input datetime like this 2005-04-19 12:00:00.000 it is not shown in view_calls_sort.inc.php, Can any one help me with this. Thanks
Try encoding it:
var value = $("#datepicker").val();
$("#firstp").load("view_calls_sort.inc.php", { datepicker: value });
or:
$("#firstp").load("view_calls_sort.inc.php?datepicker=" + encodeURIComponent(value));
Also make sure that your script
tag is inside your <html>
tag and not as it is currently shown in your question.
First, make sure that the function is called.
<script type="text/javascript">
function test_function(){
alert($("#datepicker").val());
$("#firstp").load(
"view_calls_sort.inc.php?datepicker="+$("#datepicker").val());
}
</script>
If the alert shows up, the method is called. And you get to see which value is sent to the server.
You also could change the php script and have it return a fixed value (echo 'Foo';
) so you can see if the script is called.