0

<input name="member_name" id="member_name" />

I am trying to add multiple values to hidden text box array using jquery.

<input type="hidden" name="member_names[]" id="member_names">

$('input[name="member_names[]"]').val($('#member_name').val());

1
  • what are you trying to do? please provide jsfiddle. Commented Nov 3, 2015 at 8:24

2 Answers 2

2

You can't use multiple value of type hidden. If you want this , you have to use a separator for multiple value in single hidden type.

Sign up to request clarification or add additional context in comments.

Comments

0

Create a javascript array and store values in that array, than using JSON.stringify function to set the values of input.

This method will assign the array values to input in comma separated form.

var elementsArray = [];
elementsArray.push('1');
elementsArray.push('2');
elementsArray.push('3');

$('#input_hidden_field').val(JSON.stringify(elementsArray));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.