Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js get target foreach

handleSubmit(event) {
    event.preventDefault();

    let target   = event.target;
    let formData = {};

    for (let i = 0; i < target.length; i++) {
        formData[target.elements[i].getAttribute("name")] = target.elements[i].value;
    }
    console.log('formData', formData); 
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #target #foreach
ADD COMMENT
Topic
Name
2+6 =