I have basic knowledge in programming, but unfortunately I don’t know JS that well and I’m stuck at one point.
Is there a simple way how I can get the value of a certain cell, for example the value of cell A2, and store it in a JS variable or output it via this variable elsewhere in Bubble.io?
Now I want to read the result of cell E1, for example, and output it as a variable in Bubble so that I can save it to the Bubble database or insert it elsewhere.
I hope these screenshots tell you something? Thank you very much for your help!
Yes, the table works. I can edit the cells and the formulas work as well. Everything looks fine so far (unless the debug error).
But now, how can I save a value of a specific cell into a general JS variable so that I can output it elsewhere on the same Bubble website page or save it to the Bubble database? (I hope it is understandable what I mean )
If I see it correctly, I need to change the cell 0,0
a.) change and
b.) click on the button
to save the value of cell 0,0 in the variable myVariable and show it on the page, right?
Is it possible to keep myVariable always in sync with the value of cell 0,0? (without changing and clicking)
I would like to display myVariable elsewhere on the web page or save it as a key value in the database without the user having to click a “Save” button or similar.
The save button is only there for us to check if it works
This part of the demo
afterChange: function(changes, src) {
if (changes) {
let row = changes[0][0];
let col = this.propToCol(changes[0][1]);
if (row == 0 && col == 0) {
myVariable = changes[0][3]
}
}
}
keeps the data in the variable in sync. No matter how it is changed (from a call to a server, from an edition, copy-paste or autofill) you always have an actual value of that cell.
Is it possible to show the current value in cell 0,0 beneath the table before changing (immediately after table is rendered for first time) and after changing the cell.
Now, the myValue is filled with the value of cell 0,0 only after I make a change, right?
When I click the button before I change the cell, it shows “undefined”.
If you would like to show value as it is typed that I suggest the beforeKeyDown event instead of the beforeChange/afterChange as those are triggered after the editor is closed.