smart_options: Creates HTML option tags for each position of a list of...

Description Usage Arguments Value Examples

View source: R/webdeveloper.R

Description

Creates HTML option tags for each position of a list of values and labels by calling html5::option(), returning a string of HTML to pass to a select tag through html5::select().

Usage

1
smart_options(x, value, label, selected_value, add_blank = FALSE)

Arguments

x

A named list, one name should refer to a vector of values, one name should refer to a vector of labels equal in length to the values.

value

The name of the position in x to use as the value attribute for each option tag.

label

The name of the position in x to use as the displayed content for each option tag.

selected_value

A value in the vector passed as value to mark as the initially selected option in the select tag.

add_blank

TRUE/FALSE, if TRUE, adds a blank ("") option tag.

Value

A string, with an option tag each row of x.

Examples

1
2
3
4
5
6
7
smart_options(
x = list(col1 = c("1", "2", "3"), col2 = c("New York", "Los Angeles", "Chicago")),
value = "col1",
label = "col2",
selected_value = "3",
add_blank = TRUE
)

webdeveloper documentation built on Feb. 5, 2021, 5:07 p.m.