traekdjf
traekdjf

Reputation: 123

Jquery not send values when form is submit

I using this component: https://github.com/xoxco/jQuery-Tags-Input

and I have this code:

    <script type="text/javascript">
            $(document).ready(function () {
                $('#tags_3').tagsInput({
                    width: 'auto',
                    'delimiter': [',', ';'],
                    autocomplete_url: '{{ pageTemplate.pageHeader.webUrl }}/addPhoto/tags',
                    'onChange': function () {
                        var text = $('.tagsinput').val();
                        alert($('#tags_3').tagsInput('items'));
                        $("#tags_3").val($('#tags_3_tagsinput').val());
                    }
                });

            });

        </script>

    <form method="post" name="contactformXX" class="form validate clearfix validate-form"
                              action="bla.html" enctype="multipart/form-data">


    <textarea id="tags_3" class="form-control kontakt_input tags" rows="4" id="slowa_kluczowe1"
                                          name="keywords" placeholder="Wpisz słowa kluczowe"></textarea>

<button type="submit" class="btn btn-danger kontakt_button margin_50 button_mop_r_poczta">save</button>
    </form>

When I click the "save" button, the data from the "keywords" text is not visible in the $ _POST variable in PHP.

How to fix it?

http://serwer1356363.home.pl/pub/test/index.php - here is preview

Upvotes: 0

Views: 58

Answers (1)

Michał Perłakowski
Michał Perłakowski

Reputation: 92521

You should use <input> instead of <textarea>. This plugin only works with <input>s. Also, you should remove the onChange callback – #tags_3_tagsinput is not an input, so it doesn't have a value, so the .val() method returns ''.

Upvotes: 1

Related Questions