javascript - Append Hidden input fields and bind them to the Model -
I am using a 3rd party file uploader (backlog) to upload images; Javascript to get the uploaded image name I want to pair the list of image names in my MVC model. My requirement is to dynamically create hidden information when I submit the form. I know, I have to use sequential binding with loop. Can someone help me use appropriate syntax to achieve this? It is for
(int i = 0; i & lt; noOfImages; i ++) {& lt; The input type = "hidden" should be similar to the name = "model. Images [I] .name" value = file. Name / & gt; } (Please note that I do not want Ajax solution for this and please show me the code to use in my razor view or if there is any other better solution, please let me know). . Thank you. Public Sector Madmodel {Receive Public Entry ID; Set; } Public string name {get; Set; } Public virtual iconging & lt; ImageModel & gt; Images {get; Set; }} Public Class ImageMeld {Receive Public Ent ID; Set; } Public string name {get; Set; } Receive public virtual item item {item; Set; }}
After getting the value of the uploaded file name and submitting a button to #ItemCreate, I use the following javascript code to create hidden inputs. Function () {$ ('# ItemCreateForm'). Attachments ('& lt; input name = "ImageName
$ (' #imageupploaded input [name =" image name "])." Value = "'+ this.value +'" /> ');
I am adding the following question to my question: Give me a quote and two plus sign I ['I +'] is now working fine.
$ ('# image embedded input [name = "image name"]). Each (function () {for ( Int i = 0; i & lt; no of images; i ++) {& lt; input type = "hidden" name = "images [+ 'I']. Name" value "=" '+ this.value + '"/> Gt;}
I can not use (.) For loop here. Can anyone recommend a way to get all the image names in the above table ?
You right it in the loop at the top But once you participate in javascript, you enter names. Put the name of the input in the same style for the loop first and you will be okay, i.e. images [n] .name
where n
is the index item in the archive.
Comments
Post a Comment