1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Added optional $event param to SelectorOptions()

This commit is contained in:
billz 2019-12-26 06:16:13 +00:00
parent bbe430028c
commit 6d7aa1b401

View File

@ -142,19 +142,21 @@ function isAssoc($arr)
/**
*
* Display a selector field for a form. Arguments are:
* $name: Field name
* $options: Array of options
* $selected: Selected option (optional)
* If $options is an associative array this should be the key
*
* @param string $name: Field name
* @param array $options: Array of options
* @param string $selected: Selected option (optional)
* @param string $id: $options is an associative array this should be the key
* @param string $event: onChange event (optional)
*/
function SelectorOptions($name, $options, $selected = null, $id = null)
function SelectorOptions($name, $options, $selected = null, $id = null, $event = null)
{
echo '<select class="form-control" name="'.htmlspecialchars($name, ENT_QUOTES).'"';
if (isset($id)) {
echo ' id="' . htmlspecialchars($id, ENT_QUOTES) .'"';
}
if (isset($event)) {
echo ' onChange="' . htmlspecialchars($event, ENT_QUOTES).'()"';
}
echo '>' , PHP_EOL;
foreach ($options as $opt => $label) {
$select = '';