function formSetup() {
    var form = getElement("bid_register_button")
    form.onclick = function() { formProcessBid() }
}

function formProcessBid() {
    console.log("formProcessBid")
    var data = formFetchData()
    console.log(data)
    sleep(2000)
    var bd = dbSetup()
    dbRegisterBid(bd, data)
}

function formFetchData() {
    var data = {}
    formKeys.forEach(function(element) {
        data[element] = getElement(element).value
    })
    return data
}

function getElement(id) {
    return document.getElementById(id)
}

function formKeys() {
    return ["brand", "number", "year", "service_type", "first_name", "second_name", "patronym", "telephone", "email", "comment"]
}

Изменить пасту