How to insert JSON string format into velo (WIX) textbox

27 Views Asked by At

I'm trying to show this JSON in textbox when the user selects 'CHART JSON' option in the dropdown

var data_chart = {"data":{"labels":["_2024_03_09","_2024_03_10","_2024_03_11","_2024_03_12","_2024_03_13","_2024_03_14","_2024_03_15"],"datasets":[{"label":"10JiFG1L7Y","type":"line","data":[0,0,0,0,0,0,802],"backgroundColor":"rgba(173,118,240,0.2)","borderColor":"rgba(173,118,240,1)","borderWidth":1},{"label":14029,"type":"line","data":[0,22,0,0,16,0,36],"backgroundColor":"rgba(29,22,1,0.2)","borderColor":"rgba(29,22,1,1)","borderWidth":1}]},"customization":{"borderWidth":1}}

To do so I used JSON.stringify(data_chart) to feed the dropdown with the "CHART JSON" value

 $w("#dropdown2").options  = [
        { label: "SQL", value: "No Code" },
        { label: "CHART JSON", value: JSON.stringify(data_chart)}
        
    ];

and insert it into the textBox:

export function dropdown2_change(event) {
    // Set the value of textBox1
    $w("#textBox1").value = $w("#dropdown2").value
}

But it shows item2 instead of the JSON, if I change it to string for example 'chart' it shows chart (as expected), how to fix this? enter image description here

0

There are 0 best solutions below