Change the doctype field based on the value when submitting the webform

i have 1 doctype with field: level1 (check), level2 (check), level (text).
i link doctype with webform have 2 field level1, level2 without level.
So i want when user submit webform, doctype will update level text by level1 or level2 (checked).
iam try use webform script like this:

this is webform client script

frappe.ready(function() {
	frappe.web_form.on("before_submit", function() {
        var level1 = frappe.web_form.doc.level1
        var level2 = frappe.web_form.doc.level2{
			type: "POST",
            method: "demo_app.demo_module.web_form.leveltest.update_level_selected",
            args: {
                level1: level1,
                level2: level2,
            callback: function(response) {

and this is webform server script

import frappe

def get_context(context):
	# do your magic here
def update_level_selected(level1, level2):
    level_selected = ""
    if level1:
        level_selected += level1
    if level2:
        level_selected += " - " + level2
    doc = frappe.get_doc("testlevel", frappe.web_form.docname)
    doc.level = level_selected
    return "Level selected updated successfully!"