jQuery UI Widgets Forums Editors DateTimeInput Form POST value empty

This topic contains 8 replies, has 2 voices, and was last updated by  YaniMan 7 years, 10 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • Form POST value empty #92570

    YaniMan
    Participant

    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,
    Janos

    Form POST value empty #92583

    Hristo
    Participant

    Hello 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 Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Form POST value empty #92593

    YaniMan
    Participant

    Hello 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.

    Form POST value empty #92599

    Hristo
    Participant

    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 Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Form POST value empty #92639

    YaniMan
    Participant

    Hello 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,
    Janos

    Form POST value empty #92662

    Hristo
    Participant

    Hello Janos,

    I tested jqxDateTimeInput and jqxCheckBox and they return values.
    It seems to work fine. Do you have any error message?

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Form POST value empty #92666

    YaniMan
    Participant

    Hello 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,
    Janos

    Form POST value empty #92684

    Hristo
    Participant

    Hello 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?light

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

    Form POST value empty #92692

    YaniMan
    Participant

    Hello 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

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.