Dynamic div programming

Ondra, Fri Jul 30 2021, 08:44PM

<--! HTML -->

<div class="tk" data-amount="40">
40%
<div class="lq"></div>
</div>

The "data-amount" variable and the label in the example->"40" needs to be pulled from the data base. Please explain best way to accomplish this?

Re: Dynamic div programming
administrator, Sat Jul 31 2021, 05:41PM

If you have custom data to be extracted from the database without the need for a bidirectional SQL cursor, then I suggest that you use a simplequery component. You can set the SQL for select directly or use the SQL designer to have it generated for you. (use the query property for the visual designer, the SQL property for the SQL statement. You can do this in PHP as well.

Suppose you want to display the HTML in the label value component. Then use the onbeforerender event of the label to apply your code.

Put a simplequery component on your form. I usually rename the component to q. Put a label component on your form.
Open the onbeforerender event on your label_1

$$q->setSQL('select * from mytable where mykey=:myk');
$$q->setStringFieldByName(':myk', $mysearch);
$myrow=$$q->simpleOpen(true); // retrieves first row, convenient if you expect only one row.

$field1=$myrow['amount'];
$this->value=
<build your html statement here>;

I'm not sure what you want to achieve, but it might be that a chart component could do the job?

Re: Dynamic div programming
Ondra, Tue Aug 03 2021, 09:42PM

Do you have a short tutorials .pdf on using Charts. I spent some time and was not able to get the Chart and ChartDBserie working.
Re: Dynamic div programming
administrator, Wed Aug 04 2021, 09:05AM

Working on it. But we'll discuss somewhere next week