Esempio n. 1
0
/**
* Builds a string of option elements from a data dictionary
* table.  String is ready to be inserted into a <select> element
* upon return.
*
*	string $table_id
*	string $curval
*	string $firstletters
*	array $matches
*	string $distinct
* RETURN
*	string Generated HTML option element string
*/
function hOptionsFromTable($table_id, $curval = '', $firstletters = '', $matches = array(), $distinct = '')
{
    // Pull data dictionary of target table
    $table = DD_TableRef($table_id);
    $rows = rowsForSelect($table_id, $firstletters, $matches, $distinct);
    // now turn it into an option list
    $retval = '';
    $picked = false;
    foreach ($rows as $row) {
        $hSELECTED = '';
        if (trim($row['_value']) == trim($curval)) {
            $hSELECTED = 'SELECTED';
            $picked = true;
        }
        $row['_value'] = trim($row['_value']);
        $row['_value'] = htmlentities($row['_value']);
        $retval .= "<OPTION VALUE=\"{$row['_value']}\" {$hSELECTED}>" . htmlentities($row['_display']) . '</OPTION>';
    }
    // Slip in one at the top if nothing selected
    if (!$picked) {
        $retval = "<OPTION VALUE=\"\" SELECTED> </OPTION> " . $retval;
    }
    return $retval;
}
Esempio n. 2
0
function index_hidden_dropdown()
{
    // Get the target table that we need
    $table_id_fk = gp('gp_dropdown');
    // Strip a leading slash from the value
    $gpletters = trim(gp('gp_letters'));
    # KFD 7/21/08, experiment
    $matches = aFromGP('match_');
    // Pull the rows from handy library routine.
    if (gp('gpv') == '2') {
        # KFD 7/21/08
        $rows = RowsForSelect($table_id_fk, $gpletters, $matches, '', true);
        #$rows=RowsForSelect($table_id_fk,$gpletters,array(),'',true);
    } else {
        $rows = rowsForSelect($table_id_fk, $gpletters);
    }
    // KFD 11/4/07.  If "version 2", then turn into a table
    if (gp('gpv') == '2') {
        ob_start();
        echo "androSelect|";
        echo "<table>";
        foreach ($rows as $idx => $row) {
            $prev = $idx == 0 ? '' : $rows[$idx - 1]['skey'];
            $next = $idx == count($rows) - 1 ? '' : $rows[$idx + 1]['skey'];
            $s = $row['skey'];
            $tds = '';
            $x = -1;
            foreach ($row as $colname => $colvalue) {
                $x++;
                if ($colname == 'skey') {
                    continue;
                }
                if ($x == 1) {
                    $value = $colvalue;
                }
                $tds .= "<td>{$colvalue}";
            }
            echo "<tr id='as{$s}' \n                     x_prev='{$prev}' x_next='{$next}' x_skey='{$s}'\n                     x_value='{$value}'\n                onmouseover='androSelect_mo(this,{$s})'\n                onmouseout = 'aSelect.hasFocus = false;'\n                onclick=\"androSelect_click('{$value}')\";                \n                >" . $tds;
        }
        echo ob_get_clean();
        return;
    }
    // Echo out the return
    foreach ($rows as $row) {
        echo $row['_value'] . "###" . $row['_display'] . "<br>";
    }
    if (Errors()) {
        $he = hErrors();
        syslog(LOG_INFO, $he);
    }
}