1
Hello.
I have a <select>
which is powered by database data. I need to manipulate this select and multiply it if the user wishes to send two different data. How the <option>
s depend on the data coming from the database, I do not have the option to use $(elemento).append('<select>...</select>');
I also need to change the "name" attribute of each <select>
to be able to pick up the values correctly in the $this->request->data
.
<div class="form-group">
<div class="col-lg-11">
<select class="form-control name="data[Model][0][sl_dinamica]" select-a-ser-replicada">
<option value="1">Valor 1</option>
<option value="2">Valor 2</option>
<option value="3">Valor 3</option>
</select>
<span class="btn-apagar"></span>
</div>
<div class="col-lg-1">
<span class="btn-adicionar"></span>
</div>
</div>
Already have some HTML? then the idea is when the user presses a button -> create a copy of select on the page with another name?
– Sergio
This is exactly the idea. The HTML of this is generated by a Cakephp helper. Either way, it’s a simple select.
– rafaslide
And do you already have some HTML we can use in the answer? (and by the way you are doing this with AJAX? if yes put this code too)
– Sergio
<div class="form-group">
<div class="col-lg-5"><select class="form-control"> <option value="1">Valor 1</option>
<option value="2">Valor 2</option>
<option value="3">Valor 3</option>
</select><span class="btn-apagar"></span></div>
</div>
– rafaslide
Good! can you put this HTML in the question? so others can see it too. They should stay inside the same
<form>
I suppose. To have a newselect
in this HTML it should be inside<div class="col-lg-5">
also?– Sergio
It can be inside, outside, anywhere. My greatest difficulty is to be able to replicate this select with another "name".
– rafaslide