by
How can we convert all elements of form to a JavaScript object?

1 Answer

0 votes
by
serializeArray already does exactly that. You just need to massage the data into your required format: function objectifyForm(formArray) { //serialize data function var returnArray = {}; for (var i = 0; i < formArray.length; i++){ returnArray[formArray[i]['name']] = formArray[i]['value']; } return returnArray; } Watch out for hidden fields which have the same name as real inputs as they will get overwritten.

Related questions

0 votes
    How do I convert a string variable jsonString into JSON object? Please help. {"phonetype":"N95","dog":"WP"} Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Why can't we Python parse this JSON data?...
asked Jan 11, 2021 by JackTerrance
0 votes
    For example, assuming I can generate this page but won't be able to hard-code the article number, ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I have json file as follows: { "status":"UP", "diskSpace": {"status":"UP","total":63279460352," ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    I have a basic dict as follows: sample = {} sample['title'] = "String" sample['somedate'] = somedatetimehere When ... 21:46:24.862000. Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    In java, how can I parse json text to get value of variables like post_id ? Here is my json text { "page": { ... ": "1234567890" } ] } Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I try to merge some object into one array I did output by q = [["99","99","99"],["9" ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am using the following function to load a PlayList of Songs from 'PlayListJSON.aspx' but somethings seems ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I want to parse a .json column through Power BI. I have imported the data directly from the server and ... simplified parsed columns. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    This my my JSON: { "maps": [ { "id": "AT", "iscategorical": "0" }, { "id": "AT", "iscategorical": "0 ... the values, How can I do it? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    Is there an 'official' way to get all input elements of a form including those outside of the form ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    All browsers are split into different parts or object that can be accessed using JavaScript. These parts are known as Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    How do we get the DOM object in JavaScript? (a) getElementbyId() (b) getObject() (c) getElement( ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    How do we create and preload an image object in JavaScript? (a) Use new keyword (b) Call Image() ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
...