KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I got a situation where I would like to read some data off a JSON format through PHP, however I am having some issues understanding how I should construct the Javascript object to create the JSON format dynamically. My scenario is as follows: <input title="QA" type="text" class="email"> <input title="PROD" type="text" class="email"> <input title="DEV" type="text" class="email"> The Javascript code I have so far goes through each input grabs the data, I am however unable to understand how to process from here on. var taskArray = {}; $("input[class=email]").each(function() { var id = $(this).attr("title"); var email = $(this).val(); //how to create JSON? }); I would like to get the following output if possible. [{title: QA, email: 'a@a.com'}, {title: PROD, email: 'b@b.com'},{title: DEV, email: 'c@c.com'}] Where the email is acquired by the input field value.
Tags (comma-separated)
Save Edits
Cancel