DOM values

This demo covers Tripous helpers that get, set, and clear element values. Different HTML elements store their user-facing value in different members: text inputs use value, checkboxes use checked, buttons use innerHTML, selects use the selected option, and normal elements use textContent.

tp.GetElementValueType() identifies which member is used. tp.val() and tp.Value() get or set through that member. tp.ClearValue() clears through the same rule. tp.Text() and tp.Html() are direct helpers for text and HTML content.

Sample elements

The buttons operate on these elements and write the results below.

button
div
Div text

Value type

tp.GetElementValueType() returns a member of tp.ElementValueType. This tells tp.val() what element member to read or write.

Get and set values

tp.Value() is a public alias over tp.val(). Passing one argument gets a value. Passing two arguments sets a value.

Clear, text, and HTML

tp.ClearValue() clears through the value type rule. tp.Text() writes text content and tp.Html() writes HTML.