Radiobutton automatic

196 views
Skip to first unread message

Gerald Weis

unread,
Oct 23, 2020, 9:16:49 AM10/23/20
to TiddlyWiki
hello friends,

i want to do this thing.

1. i input the min-value.
2. i input the high-value.
3. i input the real-value.

Now shoud the radiowidget set himself the position

My next problem is that i must count the table-rows by hand.
can this tiddlywiki do automaticly?

< min-value = low
> high-valule = high
others = standard

how can i do that

my code at the time is this
kzu_tab define the table-head
kzu_ein define the table-input

\define kzu_tab()
<thead>
<tr valign=top align=left>
<th class=th-allg rowspan=2>Datum</th>
<th class=th-allg rowspan=2>Norm (kg)</th>
<th class=th-allg rowspan=2>Gewicht</th>
<th class=th-allg colspan=3>Wertung</th>
</tr>
<tr>
<th>&#8211;</th>
<th>&#9675;</th>
<th>&#10010;</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan=6>&#8211; = niedrig<br>&#9675; = Norm<br>&#10010; = hoch</td>
</tr>
</tfoot>
\end

\define kzu_ein2(datum normvon normbis gewicht  zaehler Wertung)
<tr align=right>
<td>$datum$</td>
<td>$normvon$ - $normbis$</td>
<td>$gewicht$</td>
<td><$radio field="gewicht$zaehler$" value="1"></$radio></td>
<td><$radio field="gewicht$zaehler$" value="2"></$radio></td>
<td><$radio field="gewicht$zaehler$" value="3"></$radio></td>
\end

TW Tones

unread,
Oct 23, 2020, 5:19:33 PM10/23/20
to TiddlyWiki
Gerald a Quick brain dump


1. i input the min-value.
2. i input the high-value.
3. i input the real-value.


Use three edit-text widgets to edit three fields in a separate config tiddler,  in-value high-value and real-value.

 
Now should the radiowidget set himself the position

I am not sure what the radio widget supposed to do?
 

My next problem is that i must count the table-rows by hand.
can this tiddlywiki do automaticly?

What determines the number of rows, and how are you generating them?

A list that calls kzu_ein2?

 

< min-value = low
> high-valule = high
others = standard

how can i do that

What do you want to do with the values given?
 

my code at the time is this
kzu_tab define the table-head
kzu_ein define the table-input

More a table row, yes. The input is elsewhere.
Here you are NOT closing the </tr> 

Regards
Tones

Gerald Weis

unread,
Oct 28, 2020, 4:44:41 AM10/28/20
to TiddlyWiki
Also hier nochmal das ganze verständlich

ich gebe 3 Werte ein

1. den Minimalwert
2. den Maximalwert
3. den realgemessenen Wert

Nun soll der Radiowidget automatisch den Wert in der Anzeige verändern.

Ist der realgemessene Wert < als  der Minimalwert , dann soll Wert auf 1 gesetzt werden.
Ist der reaögemessene Wert > als der Maximalwert, dann soll Wert auf 3 gesetzt werden.
Ansonsten ist Wert auf 2 zu setzen.

Dies dient der Übersicht wie sich der Wert verändert hat, ob er im Normbereich liegt, oder ob er sich nach oben oder unten bewegt hat.

Das nächste Problem ist, dass ich die Zeilen per hand numerieren muss. Kann man dies auch automatisch machen?


kzu_ein ist ein Makro das folgende Werte enthält.

datum,
normvon (Minimalwert eines Körperwertes in zahlen mit Dezimalstellen)
normbis (Maximalwert eines Körperwertes in Zahlen mit Dezimalstellen)
 gewicht (Körperwert in Zahlen mit Dezimalstellen)
zaehler (Nummer  der Zeile)
Wertung:
(Radiobutton niedrig - value=1)
(Radiobutton Norm - value=2)
(Radiobutton hoch - value=3)
Dieser Wert soll anhand der Werte
Minimalwert(normvon)
 Maximalwert(normbis)
 Messwert(gewicht)
automatisch gesetzt und angezeigt werden.

Weitere Aktionen sollen nicht mehr erfolgen.

Gerald Weis

unread,
Oct 28, 2020, 5:21:46 AM10/28/20
to TiddlyWiki
Sorry
in english now

So here again the whole thing is understandable

I enter 3 values

1. the minimum value
2. the maximum value
3. the real measured value

The radio widget should now automatically change the value in the display.

If the real measured value is <than the minimum value, then the value should be set to 1.
If the real measured value is> than the maximum value, then the value should be set to 3.
Otherwise the value should be set to 2.

This provides an overview of how the value has changed, whether it is in the normal range, or whether it has moved up or down.

The next problem is that I have to number the lines by hand. Can you do this automatically?


kzu_ein is a macro that contains the following values.

date,
normvon (minimum value of a body value in numbers with decimal places)
normbis (maximum value of a body value in numbers with decimal places)
weight (body value in numbers with decimal places)
counter (number of the line)
Rating:
(Radio button low - value = 1)
(Radio button Norm - value = 2)
(Radio button up - value = 3)
This value should be based on the values
Minimum value (normof)
Maximum value (normal to)
Measured value (weight)
automatically set and displayed.

No further actions should take place.

Eric Shulman

unread,
Oct 28, 2020, 8:33:34 AM10/28/20
to TiddlyWiki


On Wednesday, October 28, 2020 at 2:21:46 AM UTC-7, Gerald Weis wrote:
I enter 3 values
1. the minimum value
2. the maximum value
3. the real measured value

The radio widget should now automatically change the value in the display.
If the real measured value is <than the minimum value, then the value should be set to 1.
If the real measured value is> than the maximum value, then the value should be set to 3.
Otherwise the value should be set to 2.
This provides an overview of how the value has changed, whether it is in the normal range, or whether it has moved up or down.

If I understand correctly, it would seem that want to use the radio buttons for *display* only, not as input controls that can be changed.

If that is the case, then why not just use text output (e.g., "low", "high", "normal")?  Something like this:
min: <$edit-text field="minval" />
max
: <$edit-text field="maxval" />
real
: <$edit-text field="realval" />

<$list filter="[{!!realval}compare:number:lt{!!minval}]">
   LOW
</$list>
<$list filter="[{!!realval}compare:number:gt{!!maxval}]">
   HIGH
</
$list>
<$list filter="[{!!realval}compare:number:gteq{!!minval}then{!!realval}compare:number:lteq{!!maxval}]">
   NORMAL
</$list>

If you must use radio buttons as output, then you don't actually need the TiddlyWiki <$radio> widget,
and instead, can use "plain" HTML radio buttons to produce the desired display, like this:

min: <$edit-text field="minval" />
max
: <$edit-text field="maxval" />
real
: <$edit-text field="realval" />

<$list filter="[{!!realval}compare:number:lt{!!minval}]">
   
<input type=radio checked />
   
<input type=radio />
   
<input type=radio />
</$list>
<$list filter="[{!!realval}compare:number:gt{!!maxval}]">
   <input type=radio /
>
   
<input type=radio />
   
<input type=radio checked />
</$list>
<$list filter="[{!!realval}compare:number:gteq{!!minval}then{!!realval}compare:number:lteq{!!maxval}]">
   <input type=radio /
>
   
<input type=radio checked />
   
<input type=radio />
</$list>

You can, of course, place the above bits of syntax inside a table layout to further suit your desired display.  I leave that to you to work out.

enjoy,
-e

Gerald Weis

unread,
Oct 31, 2020, 3:44:33 AM10/31/20
to TiddlyWiki
Hi Guys,
first of all thanks for your help.
But this solution works wonderfully for one line,
but how do i make it dynamic?
My table currently has 15 rows. and at least one line is added every week.

Eric Shulman

unread,
Oct 31, 2020, 4:49:02 AM10/31/20
to TiddlyWiki
On Saturday, October 31, 2020 at 12:44:33 AM UTC-7, Gerald Weis wrote:
this solution works wonderfully for one line,
but how do i make it dynamic?
My table currently has 15 rows. and at least one line is added every week.

I assume that the rows of the table are stored as separate tiddlers, where each tiddler has fields: minval, maxval, and realval.

Then you could write something like this:
\define showRadioButtons()

<$list filter="[{!!realval}compare:number:lt{!!minval}]">
   
<input type=radio checked />
   
<input type=radio />
   
<input type=radio />
</$list>
<$list filter="[{!!realval}compare:number:gt{!!maxval}]">
   <input type=radio /
>
   
<input type=radio />
   
<input type=radio checked />
</$list>
<$list filter="[{!!realval}compare:number:gteq{!!minval}then{!!realval}compare:number:lteq{!!maxval}]">
   <input type=radio /
>
   
<input type=radio checked />
   
<input type=radio />
<
/$list>
\end

<table>
<$list filter="[has[minval]has[maxval]has[realval]]">
   <tr>
      <td> <<currentTiddler>> </
td>
     
<td> <<showRadioButtons>> </td>
   </
tr>
</$list>
</
table>

Notes:
* For readability, I have placed the radiobutton display code into a macro called <<showRadioButtons>>

enjoy,
-e

Gerald Weis

unread,
Oct 31, 2020, 6:00:47 AM10/31/20
to TiddlyWiki
Hello Eric,
Unfortunately, NOT every entry is a separate tiddler. That's why I also have the counter variable in my macro kzu_ein2. It defines the number of the row in the table.

The macro kzu_tab defines the head of the table. This table header is used in exactly the same way for other tables.

kzu_ein2 defines the input line of the table. This macro is called for every row in the table, currently 15 times in the table.

The entries are made in the following order.

1st date
2. Norm of
3. Norm to
4. real
5. Line number

Then click the radio button that corresponds to the conditions:

1. If real <norm of, then low
2. Is real> norm up, then high
3. If real> = norm from and <= norm to, then normal

I'll attach a picture of the table in the view and in the edit mode. The line number is only used for counting up.
Bildschirmfoto vom 2020-10-31 10-58-29.png
Bildschirmfoto vom 2020-10-31 10-59-20.png
Bildschirmfoto vom 2020-10-31 10-57-30.png

Eric Shulman

unread,
Oct 31, 2020, 12:59:47 PM10/31/20
to TiddlyWiki
On Saturday, October 31, 2020 at 3:00:47 AM UTC-7, Gerald Weis wrote:
Hello Eric,
Unfortunately, NOT every entry is a separate tiddler. That's why I also have the counter variable in my macro kzu_ein2. It defines the number of the row in the table.
The macro kzu_tab defines the head of the table. This table header is used in exactly the same way for other tables.
kzu_ein2 defines the input line of the table. This macro is called for every row in the table, currently 15 times in the table.

I think you would be better off using the power of TiddlyWiki to construct
the table output from separate tiddlers that hold the data in fields rather
than hard-coding literals as macro parameters.  This would allow you
MUCH more flexibility to reference the stored field values in other places.

However, given your current implementation, try this:
\define kzu_ein2(datum normvon normbis gewicht  zaehler Wertung)
<tr align=right>
<td>$datum$</td>
<td>$normvon$ - $normbis$</
td>
<td>$gewicht$<
/td>
<td>
   <$list filter="[[$gewicht$]compare:number:lt[$normvon$]]"
      emptyMessage="<input type=radio /
>">

      <input type=radio checked />
   </$list>
</td>
<td>
   <$list filter="
[[$gewicht$]compare:number:gt[$normbis$]]"
      emptyMessage="
<input type=radio />">

      <input type=radio checked />
   </$list>
</$list>
</td>
<td>
   <$list filter="
[[$gewicht$]compare:number:gteq[$normvon$]then[$gewicht$]compare:number:lteq[$normbis$]]"
      emptyMessage="
<input type=radio />">

      <input type=radio checked />
   </$list>
</td>
\end

Notes:
* Each $list compares the "$gewicht$" parameter value with the $normvon$ and/or $normbis$ values,
and, if the comparison is true, it shows a checked radio button; otherwise it shows an unchecked radio button
* Since you are passing in values for normvon, normbis, and gewicht, there is no need to use
"gewichtNN" field values to hold "1", "2" or "3"

Also... since you are hand-coding and passing constant values into the macro just to
produce formatted table output, you could omit all the macros, and just using wikitext
table syntax directly, like this:

|!Datum |!Norm (kg) |!Gewicht |>|>|>|!Wertung |
|! |! |! |! - |! 0 |! + |
|18.09.2020 |55,3 - 67,6 | 68,0|<input type="radio">|<input type="radio">|<input type="radio" checked>|
|01.07.2020 |56,7 - 69,4 | 69,8|<input type="radio">|<input type="radio">|<input type="radio" checked>|
|11.03.2020 |56,5 - 69,0 | 70,6|<input type="radio">|<input type="radio">|<input type="radio" checked>|
...etc...
|>|>|>|>|>|!- = Neidrig, 0 = Norm, + = Hoch|

-e

Gerald Weis

unread,
Nov 1, 2020, 5:22:58 AM11/1/20
to TiddlyWiki
Hello Eric,

thankyou for your help.
You are great.
Reply all
Reply to author
Forward
0 new messages