Suppose I have a list of items in a view:
<% Dim valor As New List(Of Integer)
For i As Integer = 0 To 5%>
<%valor.Add(i)%>
<% Next%>
I send them to a modal using data like this:
<a href="#" data-toggle="modal" data-target="#modal_noticia_editar" data-valores='<%:valor%>' data-noticiaid='<%: item.IdNoticia%>' data-titulo='<%: item.TituloNoticia%>' data-descripcion='<%: item.DescripcionNoticia%>' class="noticia_edit">Editar</a>
And when the modal is opened, data appears where I do it this way:
$('.noticia_edit').click(function (e) {
e.preventDefault();
NoticiaID = $(this).data('noticiaid');
Titulo = $(this).data('titulo');
Descripcion = $(this).data('descripcion');
valores = $(this).data('valores');
$("#modal_noticia_editar input[name=noticiaid]").val(NoticiaID);
$("#modal_noticia_editar input[name=titulo]").val(Titulo);
$("#modal_noticia_editar input[id=Descripcion_edit]").val(Descripcion);
$("#modal_noticia_editar input[id=foto_multi]").val(valores);
});
In this line
$("#modal_noticia_editar input[id=foto_multi]").val();
to val
, I must pass the list "values".
For this I need to go through the list and I would like to know how to send the list elements values with jquery or javascript to the val input[id=foto_multi]")
so that the elements of this list are displayed.
could you see to use
then when you use the data-values='<%:value%>' you would be passing these separated by commas, in the val() they would be shown directly