0

I'd like to store some data from inputs and store them to an array.

Example:

input 1: [some text]
input 2: [more text]
input 3: [some more]

As I click save, the values in these 3 inputs should be saved to an array so that later on I can print them like this:

Array[1] has: some text, more text, some more
Array[2] has: name1, name2, name3

This is what I have so far: http://jsfiddle.net/P7QXa/

Thanks in advance

1 Answer 1

2

You can use .map() like this

var arr = $('input:text').map(function(){
             return this.value;
          }).get();

Demo ---> http://jsfiddle.net/P7QXa/1/

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

1 Comment

Thanks. This did the trick, modified a little to get the expected output: jsfiddle.net/P7QXa/3

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.