Notifications
Clear all

[Solved] Write value from database table to variable

8 Posts
2 Users
0 Reactions
2,265 Views
(@i-fischer)
Posts: 5
Member
Topic starter
 

Is there a possibility to take over a certain value from the Database Table with a mouse click?
For example, I have a database with 10 entries that is displayed in the Database Table. Now I want to click on one of these entries and the selected value is written into a variable.

...or is there perhaps another way to realise this ?


 
Posted : 14/04/2023 4:06 p.m. CET
Matthias
(@m-folte-9469)
Posts: 34
Member Admin
 

Hello,

there is no "out-of-the-box" possibility to write a value from a DatabaseTable into a variable.

However, this is still possible through the use of JavaScript. Please have a look at the demo project that I have just created for you: https://www.indi-an.com/help_quickhmi/demoprojects/hawk/100301_write_variable_from_databasetable.qpro

You can find more demo projects on the topic of JavaScript here: https://www.quickhmi.de/help_quickhmi/actual/online/de/example_projects.html


 
Posted : 17/04/2023 3:00 p.m. CET
(@i-fischer)
Posts: 5
Member
Topic starter
 

Thank you for your feedback. I will test it in the course of the week.


 
Posted : 18/04/2023 8:50 a.m. CET
(@i-fischer)
Posts: 5
Member
Topic starter
 

The example works quite well and I have already integrated the function into my project.

Now a question has arisen:

When I call the function with 

$(document).on("click", ".DatabaseTable td", function(e)

it reacts to every Database Table (that's how you described it).

However, in your example, "[elementid=1_0] td" was specified, which limits execution to a specific table (I assume).

In the hint text you specify a page ID = 1 and an element ID = 0. How can I tell in the project which ID my page has and which ID the element has ?


 
Posted : 21/04/2023 4:16 p.m. CET
Matthias
(@m-folte-9469)
Posts: 34
Member Admin
 

In the tooltip of an element (if you hover the mouse over an element in the editor) you can see the ID of the element. Unfortunately, the page ID is not displayed anywhere at the moment. To get the ID in the current version, you have to start the developer tools (F12 in Chrome) at runtime (when you open it in Chrome, for example) and select the element.

However, I will take your question as an opportunity to expand the tooltip of an element to include the page ID.


 
Posted : 25/04/2023 8:15 a.m. CET
(@i-fischer)
Posts: 5
Member
Topic starter
 

The element ID was quite easy to find, but I can't find the page ID in the developer tools.

Where exactly is the page ID hiding? Can you possibly send me a screenshot. Maybe I am looking in the wrong place.


 
Posted : 28/04/2023 9:26 a.m. CET
Matthias
(@m-folte-9469)
Posts: 34
Member Admin
 

The Element_ID you find in the developer tools of your browser is already a combination of page ID and element ID.
In the example 1_0, the page ID would be "1" and the ID of the element on the page would be "0".


 
Posted : 28/04/2023 12:35 p.m. CET
(@i-fischer)
Posts: 5
Member
Topic starter
 

Now I have understood it 😊 and found it !

It's quite easy if you select source code in the debugger and go to (Index). Then simply click on an element (button is best, as the whole thing runs quite slowly) and it is then displayed on the right in the code window, e.g. "onClickQHMIButton('11_36')". This way you have the page. The rest is quite simple.

Thanks again !


 
Posted : 28/04/2023 2:36 p.m. CET