You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.3 KiB
43 lines
1.3 KiB
|
|
const test = () => console.log("Hallo Welten!");
|
|
|
|
function convertToJsonDict(form) {
|
|
|
|
let formData = {};
|
|
for (let i = 0; i < form.elements.length; i++) {
|
|
let element = form.elements[i];
|
|
if (element.type !== "submit" && element.type !== "button" &&
|
|
element.name !== "csrfmiddlewaretoken") {
|
|
formData[element.name] = element.value;
|
|
}
|
|
}
|
|
return formData;
|
|
}
|
|
|
|
const savePlanningparameter = (htmlform) => {
|
|
|
|
let headers = {
|
|
'X-Requested-With': 'XMLHttpRequest',
|
|
'Content-Type': 'application/json',
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
}
|
|
console.log("!!!!");
|
|
console.log("Änderung: ",htmlform);
|
|
|
|
let formName = htmlform.getAttribute("name").slice(4);
|
|
//console.log("Formname: ",formName);
|
|
let jsonFormDict = convertToJsonDict(htmlform)
|
|
console.log("JSONDict: ",jsonFormDict)
|
|
let bodyDict = {"modelName": formName}
|
|
bodyDict['data'] = convertToJsonDict(htmlform)
|
|
console.log("bodyDict ",bodyDict)
|
|
let body = JSON.stringify(bodyDict)
|
|
console.log("Body: ",body)
|
|
let response = fetch('/save_planungsparameter/', {
|
|
method: 'POST',
|
|
headers: headers,
|
|
body: body
|
|
}
|
|
)
|
|
}
|
|
// https://www.parvatiandsons.in/resource/how-to-add-onchange-event-in-django-python/
|