jquery - store and duplicate input changing id x times -


Hi friends, I was the best way to overcome this:

I have Input element within a hidden area div Get the input with id = 'upload_logo' on the page load, then generate the x amount of time and add it to the same div < Once / code> updating names and id each time.

  & lt; Div id = "hidden_fields" & gt; & Lt; Input type = 'hidden' class = 'hidden' name = 'upload_logo' id = 'upload_logo' value = 'filepath / filename.eps' / & gt; & Lt; / Div   

will generate:

  & lt; Div id = "hidden_fields" & gt; & Lt; Input type = 'hidden' class = 'hidden' name = 'upload_logo' id = 'upload_logo' value = 'filepath / filename.eps' / & gt; & Lt; Input class = "hidden" type = "hidden" id = "upload_logo_x" name = "upload_logo_x" value = "filepath / filename.eps" & gt; & Lt; Input class = "hidden" type = "hidden" id = "upload_logo_x" name = "upload_logo_x" value = "filepath / filename.eps" & gt; & Lt; Input class = "hidden" type = "hidden" id = "upload_logo_x" name = "upload_logo_x" value = "filepath / filename.eps" & gt; & Lt; / Div    

You can use for loop For this, have it. Your hidden_filld is your #hidden_fields element, upload_logo is your #upload_logo element and number The number of elements that you want to create.

  var hidden_fields = $ ('# hidden_fields'), upload_logo = $ ('# upload_ logo'), number = 3; (Var i = 0; i & lt; 3; i ++) $ ('& lt; input / & gt;', {type: 'hidden', 'class':' hidden ', id:' upload_logo_ '+ I, name:' Upload_logo_ '+ i, value: upload_logo.val ()}). Enclosure (Hidden_field);   

.

Fields are hidden, here's a screenshot of what has been generated:

 example

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -