Habeeb Rahman
Habeeb Rahman

Reputation: 405

How to Copy Text From One Multiple Input To Another

I have two multiple input fields as shown below.

<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>

Now when I input some value in the first mark[] then I want to copy it to the first remark[]. How to do this using jQuery or script?

Upvotes: 0

Views: 88

Answers (1)

Kiran Shahi
Kiran Shahi

Reputation: 7970

You input event and find next div with $(this).next("input[name='remark[]']")

$("input[name='mark[]']").on('input', function() {
  $(this).next("input[name='remark[]']").val($(this).val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>
<input name='mark[]'/><input name='remark[]'/><br/>

Upvotes: 3

Related Questions