I'm trying to use the new Button function to read values from a Data Blaze table but it doesn't seem to update my values when clicked whereas if I contain my DBselect function inside a form toggle instead it does work. Here's my snippet. Obviously you won't be able to load my table data in this example. Any advice would be appreciated.
{button: {dbselect: SELECT hour, minutes, datepicker, date FROM appointment offer time ORDER BY name DESC; space=2iX7iNMAHWPmJ8RnPECW9N; menu=no}; label=Read from DB}
{formtoggle: default=no; name=Read from DB}{dbselect: SELECT hour, minutes, datepicker, date FROM appointment offer time ORDER BY name DESC; space=2iX7iNMAHWPmJ8RnPECW9N; menu=no}{endformtoggle}
You need to move the end of the form toggle to the end of the snippet, like this:
{button: {dbselect: SELECT hour, minutes, datepicker, date FROM appointment offer time ORDER BY name DESC; space=7AFvdjvEPJdSAWEoLrURvO; menu=no}; label=Read from DB}
{formtoggle: default=no; name=Read from DB}{dbselect: SELECT hour, minutes, datepicker, date FROM appointment offer time ORDER BY name DESC; space=7AFvdjvEPJdSAWEoLrURvO; menu=no; multiple=no}
Forget the formtoggle. I just want the button to activate pulling data from a DataBlaze table. Is that something that's possible? You don't have access to that table so you'll have to create your own to test this.
{button: {dbselect: SELECT hour, minutes FROM `appointment offer time` ORDER BY name DESC; space=6Q59aiM0OB7DxTgDnEHJDS; menu=no}; label=Read from DB}
Time:{formmenu: 10; 11; default=12; 1; 2; 3; 4; 5; 6; 7; name=hour}:{formmenu: default=00; 10; 15; 20; 30; 40; 45; 50; name=minutes}
{=hour}
{=minutes}
You need to manually store the result of the {dbselect} into a variable, and then access its properties using its keys.
Try this:
{button:
result = {dbselect: SELECT hour, minutes FROM `appointment offer time` ORDER BY name DESC; space=6Q59aiM0OB7DxTgDnEHJDS; menu=no}
hour = result.hour
minutes = result.minutes
; label=Read from DB}
Time:{formmenu: 10; 11; default=12; 1; 2; 3; 4; 5; 6; 7; name=hour}:{formmenu: default=00; 10; 15; 20; 30; 40; 45; 50; name=minutes}
{=hour}
{=minutes}
When you use {dbselect} outside a {button}, its selected variables (SELECT hour, minutes) are exposed globally automatically.
When you use {dbselect} inside a {button} (or any other code block), its selected variables are not exposed globally automatically, and you need to manually store it in a variable and extract its results (like I did above).
Ahhhh, brilliant! Thanks so much, that solved it. Code blocks are so new that it wasn't clear to me the contained nature of them but that's so cool how it works. Thanks so much