Bootstrap Tags: how to get elements from input list to server?

I am currently using the following library: Boot Tags

The user interface works great. But I am confused how to get all the values ​​inside the input field? (I want the entire tag list to be entered by the user) and send that information to the server. (I want to print using javascript first and then send to server using post request)

$("input").val()
$("input").tagsinput('items') //this is giving me error message

      

Here is my code:

 <!-- Textarea -->
                <div class="form-group">
                  <label class="col-md-3 control-label" for="textarea">Search Tags</label>
                  <div class="col-md-8">
                      <input class="form-control" id="tagTextarea" data-role="tagsinput" id="tagsInput" />
                  </div>
                </div>
                <script>
                    $('input').tagsinput({
                        trimValue: true

                    }

                    );
                    $('input').on('beforeItemAdd', function(event) {

                        // event.item: contains the item
                        // event.cancel: set to true to prevent the item getting added
                       //Now how do i retrieve those values inside?
                        console.log(tags);//<--how to print value?
                      });
                </script>

      

+3


source to share


1 answer


Ypu can use serialize

jquery function to get all form values.

$('#formId').serialize();

      



You can view the result provided by this function for client-side printing, and also send the same result to server-side code.

You can go jQuery serialize ()

+2


source







All Articles