Thanks Yisrael,
already found a solution, but it is still not the end-one…
export async function btnAddList_click(AUSWAHL) {
let myArray0 = ["field1", "field2", "field3", "field4", "field5", "field6", "field7", "field8", "field9", "field10"]
let myArray1 = []
let myArray2 = []
console.log("CopyData: ", copyDATA)
console.log("Settings-Data = ", settingsDATA)
console.log("Settings-Data = ", settingsDATA.items)
console.log("Settings-Data = ", settingsDATA.items[1])
//Prüfen auf Erstauswahl (Checkboxen)
if (state===undefined) {
//zeige Auswahlfenster...
$w('#boxSelection').show('float')
$w('#btnTitle').label = settingsDATA["setup1"]
}
// var person = {firstName:"Donald", lastName:"Trump", age:50, country:"Bolivia"};
else {console.log("Auswahl bereits getätigt.")
console.log("CB-VALUE:", $w('#cbgListCopy').value)
//---[1]----------------------------------------------------------
if($w('#cbgListCopy').value[0]!==undefined) {console.log("Value-0 = " + $w('#cbgListCopy').value[0])
myArray1.push($w('#cbgListCopy').value[0])
myArray2.push(copyDATA[$w('#cbgListCopy').value[0]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = ({[myArray0[0]]: myArray2[0]})
console.log("myFilter =", myFilter)
}
//---[2]----------------------------------------------------------
if($w('#cbgListCopy').value[1]!==undefined) {console.log("Value-1 = " + $w('#cbgListCopy').value[1])
myArray1.push($w('#cbgListCopy').value[1])
myArray2.push(copyDATA[$w('#cbgListCopy').value[1]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = [{[myArray0[0]]: myArray2[0], [myArray0[1]]: myArray2[1]}]
console.log("myFilter =", myFilter)
}
//---[3]----------------------------------------------------------
if($w('#cbgListCopy').value[2]!==undefined) {console.log("Value-2 = " + $w('#cbgListCopy').value[2])
myArray1.push($w('#cbgListCopy').value[2])
myArray2.push(copyDATA[$w('#cbgListCopy').value[2]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = [{[myArray0[0]]: myArray2[0], [myArray0[1]]: myArray2[1], [myArray0[2]]: myArray2[2]}]
console.log("myFilter =", myFilter)
}
//---[4]----------------------------------------------------------
if($w('#cbgListCopy').value[3]!==undefined) {console.log("Value-3 = " + $w('#cbgListCopy').value[3])
myArray1.push($w('#cbgListCopy').value[3])
myArray2.push(copyDATA[$w('#cbgListCopy').value[3]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = [{[myArray0[0]]: myArray2[0], [myArray0[1]]: myArray2[1], [myArray0[2]]: myArray2[2], [myArray0[3]]: myArray2[3]}]
console.log("myFilter =", myFilter)
}
else {console.log("Value-0 = undefined")}
console.log("myFilter-JSON =", JSON.stringify(myFilter))
local.setItem("copyData", JSON.stringify(myFilter))
$w('#btnAddList').enable()
if ($w('#cbgListCopy').value.length>0) {$w('#btnShowList').enable()}
}
}
Important part is this one…
//---[1]----------------------------------------------------------
if($w('#cbgListCopy').value[0]!==undefined) {
console.log("Value-0 = " + $w('#cbgListCopy').value[0])
myArray1.push($w('#cbgListCopy').value[0])
myArray2.push(copyDATA[$w('#cbgListCopy').value[0]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = ({[myArray0[0]]: myArray2[0]})
console.log("myFilter =", myFilter)
}
//---[2]----------------------------------------------------------
if($w('#cbgListCopy').value[1]!==undefined) {
console.log("Value-1 = " + $w('#cbgListCopy').value[1])
myArray1.push($w('#cbgListCopy').value[1])
myArray2.push(copyDATA[$w('#cbgListCopy').value[1]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = [{[myArray0[0]]: myArray2[0], [myArray0[1]]: myArray2[1]}]
console.log("myFilter =", myFilter)
}
//---[3]----------------------------------------------------------
if($w('#cbgListCopy').value[2]!==undefined) {
console.log("Value-2 = " + $w('#cbgListCopy').value[2])
myArray1.push($w('#cbgListCopy').value[2])
myArray2.push(copyDATA[$w('#cbgListCopy').value[2]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = [{[myArray0[0]]: myArray2[0], [myArray0[1]]: myArray2[1], [myArray0[2]]: myArray2[2]}]
console.log("myFilter =", myFilter)
}
//---[4]----------------------------------------------------------
if($w('#cbgListCopy').value[3]!==undefined) {
console.log("Value-3 = " + $w('#cbgListCopy').value[3])
myArray1.push($w('#cbgListCopy').value[3])
myArray2.push(copyDATA[$w('#cbgListCopy').value[3]])
console.log("myArray1= ", myArray1)
console.log("myArray2= ", myArray2)
myFilter = [{[myArray0[0]]: myArray2[0], [myArray0[1]]: myArray2[1], [myArray0[2]]: myArray2[2], [myArray0[3]]: myArray2[3]}]
console.log("myFilter =", myFilter)
}
else {console.log("Value-0 = undefined")}
+++and+++
local.setItem("copyData", JSON.stringify(myFilter))
Second part of code…is the “back-parsing” of the JSON-String on another site.
You will find all given CONSOLE-LOGS on this site…
https://www.media-junkie.com/pflegeservice
connected page to this project —> https://www.media-junkie.com/list-copy
How it should work?
Selecting → rows from TABLE —> creating a new DB-entries —> view on new page.
Problem = Saving the new created and modified “ROW-DATA” back to the new DATABASE. I have trouble to create —> JSON —> {xxx: “yyy”, aaa: } inside an Array.
It works already —> but just for one line and also the CODE is really not the best one.
My aim:
It should be able to create multiple “JSON-DATA-ROWs” in an ARRAY, which then will be send via “LOCAL-STORAGE” to next page —> “NEW-LIST”.
You will find this code on the very bottom in my project.