jQuery UI Widgets › Forums › Editors › DateTimeInput › Form POST value empty
Tagged: #datetimeinput, Form POST value empty, javascript datetimeinput, jquery datetimeinput, jqwidgets datetimeinput
This topic contains 8 replies, has 2 voices, and was last updated by YaniMan 7 years, 10 months ago.
-
AuthorForm POST value empty Posts
-
Hello!
I made a simple “site” with two pages: one html with a form and one php for checking the posted values.index.html:
<!doctype html> <html> <head> <title>E!</title> <link rel="stylesheet" type="text/css" href="jqw/styles/jqx.base.css" /> <script src="jquery-3.2.0.min.js"></script> <script src="jqw/jqxcore.js"></script> <script src="jqw/jqx-all.js"></script> </head> <body> <form id="form" method="POST" action="report.php" target="_blank"> <input id="date" name="date" type="date" /> <input id="text" name="text" type="text" value="I'm good" /> <input id="check" name="check" type="checkbox" />I'm checked <input class="button" type="submit" value="Go!" /> </form> <script> $(document).ready(function() { $("#date").jqxDateTimeInput({ width: 130, formatString: "dd/MM/yyyy", textAlign: "center" }); $("#text").jqxInput({ width: 130 }); $("#check").jqxCheckBox({ checked: true }); $(".button").jqxButton(); $("#form").on("submit", function() { console.log("date = '" + $("#date").val() + "'"); console.log("text = '" + $("#text").val() + "'"); console.log("check = '" + $("#check").val() + "'"); }); }); </script> </body> </html>
report.php:
<?php echo print_r($_REQUEST, true);
I can get the date input’s value from javascript using the .val() method, but it posts and empty value to the server:
Array ( [date] => [text] => I'm good )
Also i can get the value of the checkbox in javascript but it does not even show up in the POST data.
Please advise. jQWidgets version: 4.5.0
Thanks & best regards,
JanosHello YaniMan,
This is not widget issue. I would suggest you check your settings when you do POST request.
You could try to create a simple code with POST query to check it.
Could you check is there any error message?Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello Hristo,
Thanks for the reply. However if you comment out the lines that makes jQ widgets from the inputs (jqxDateTimeInput and jqxCheckBox, ready function #1 and #3), the same code works well, so i think it is widget issue. I think the widget code removes the input element and replaces it with something else in case of the checkbox and have no idea what it does with the date entry.
Hello YaniMan,
I tested jqxInput and it seems to work fine.
I would like to suggest you use change event and when it fires you could set the value from the jqxInput to one hidden field.
You will be able to send this value (from the hidden field) with ‘POST’ request when submits the form.Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello Hristo,
Yes, jqxInput works as expected but jqxDateTimeInput and jqxCheckBox does not.
I’m doing what you’ve suggested but thought that this worth mentioning.Best regards,
JanosHello Janos,
I tested jqxDateTimeInput and jqxCheckBox and they return values.
It seems to work fine. Do you have any error message?Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello Hristov,
They return values with .val() method for me too, but when the form is posted to the server, jqxDateTimeInput posts empty value and jqxCheckBox does not appear in PHP’s $_REQUEST variable (as i wrote in my first post).
Best regards,
JanosHello Janos,
It looks like some settings to a server are incorrect, it is not widget issue.
Please, take a look at this demo:
http://www.jqwidgets.com/jquery-widgets-demo/demos/php/login_form.htm?lightBest Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHello Hristo,
If i use <div> instead of <input> and give the divs names, then it works for me too and (surprising for me) they are included in the form’s post data. I think this would worth mentioning in the documentation as i expected that the form uses data from <input>s only so i would have never guessed that i can post datas from (originally) divs too.
However, everything works now and i can skip the part where i needed to copy values into hidden inputs. Thank you very much for your help.Best regards,
Janos -
AuthorPosts
You must be logged in to reply to this topic.