The thing is that I'm working with access to the roles and I had a question about the jQuery tags, the thing is that I'm listing a list with the names of the permissions already registered and I want to assign to the role a set of attributes of permission type (this is the permissions where the role has access).
Ok, I have an example form to not paste the whole form because it is very large, but this is functional. The form would be like this:
<form id="form_create_update_accesos" name="form_create_update_accesos" method="POST">
<div class="form-group col-lg-6 col-md-6 col-sm-6 col-xs-12">
<label for="id_permiso">Permisos</label>
<select class="form-control selectpicker" data-live-search="true" name="id_permiso" id="id_permiso" required></select>
<br>
<button class="btn btn-primary btn-sm" type="button" onclick="addAtributo()">
<i class="fa fa-plus" style="font-size: 12px;"></i> Agregar Atributo
</button>
</div>
<div class="form-group col-lg-6 col-md-6 col-sm-6 col-xs-12">
<label for="atributo">Atributos de Acceso</label>
<input class="form-control" type="text" id="atributo" name="atributo" data-role="tagsinput" placeholder="Atributos de Acceso" readonly />
</div>
</form>
Now I put the function js that I am indicating the case.
function addAtributo(){
aux = document.getElementById("id_permiso").value;
setAcceso(aux);
}
Here, I try to pull the input id of the select and send it to another function to set the input of the tags, but I do not know how to set it well. Here is what I use to set but something is wrong.
function setAcceso(aux){
$("#atributo").val(aux).tagsinput({
confirmKeys: [1, 2],
maxTags: 3
});
}
It should be noted that I am using the javascript library for the input tags would be this one of js
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.js"></script>
And this one is for the css style
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tagsinput/0.8.0/bootstrap-tagsinput.css" />
In summary, I am trying the id of the select, send it to the input of the tags to be added as attributes and then save them.
Greetings.