0
Good afternoon, I’m having trouble finding a way to add value to a readonly input without eliminating the value that’s already in that input. My layout consists of two inputs and a button, the first input is a normal type text input, the second is a readonly input and have an Add button to add the value of the first input to the second it is readonly and I am trying to have the value of the readonly input never deleted by more values that are added. Thank you :)
This is my script:
function setValue() {
var nome = document.getElementById('inputNome').value;
document.getElementById('textNome').value = nome;
};
This is my HTML code:
<div class="form-group col-md-5">
<label for="inputNome">Nome</label>
<input type="text" name="inputNome" class="form-control" id="inputNome" placeholder="Nome">
</div>
<button type="button" id="btnNomes" onclick="setValue()" name="btnNomes"class="btn col-md-1 mx-1 px-0 my-auto btn-danger">Add</button> <!--Btn Add-->
<input type="text" class="form-control col-md-5 my-auto" id="textNome" name="textNome" placeholder="Nomes..." readonly /> <!--Readonly Input-->
What do you want to do with the value that is already in the input? So you will get a new value right? you want to add these values or separate by virgular? what really you need
– OtavioCapel
I would like to separate by comma, I apologize for not being clear in my question
– Afonso