Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prettier Grouped Dropdown Options?
12-07-2018, 08:30 AM, (This post was last modified: 12-07-2018, 09:11 AM by VortecCPI.)
#1
Prettier Grouped Dropdown Options?
I was going to ask how we can do what I saw in FrontAccounting last night but now I know so I am going to share because it was really simple:

   

Note <optgroup label="LABEL">
PHP Code:
    $SQLAccountSelect="SELECT chartmaster.accountcode,
                            chartmaster.accountname,
                            chartmaster.group_
                        FROM chartmaster
                        INNER JOIN glaccountusers ON glaccountusers.accountcode=chartmaster.accountcode AND glaccountusers.userid='" 
.  $_SESSION['UserID'] . "' AND glaccountusers.canview=1
                        INNER JOIN accountgroups ON chartmaster.group_=accountgroups.groupname
                        ORDER BY accountgroups.sequenceintb, accountgroups.groupname, chartmaster.accountcode"
;

    
$ResultSelection=DB_query($SQLAccountSelect);
    echo 
'<td><select name="GLCode">';    
    echo 
'<option value="">' _('Select an Account Code') . '</option>';
    while (
$MyRowSelection=DB_fetch_array($ResultSelection)){
        if (
$OptGroup != $MyRowSelection['group_']) {
            echo 
'<optgroup label="' $MyRowSelection['group_'] . '">';
            
$OptGroup $MyRowSelection['group_'];
        }
        if (isset(
$_POST['GLCode']) and $_POST['GLCode']==$MyRowSelection['accountcode']){
            echo 
'<option selected="selected" value="' $MyRowSelection['accountcode'] . '">' $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8'false) . '</option>';
        } else {
            echo 
'<option value="' $MyRowSelection['accountcode'] . '">' $MyRowSelection['accountcode'].' - ' .htmlspecialchars($MyRowSelection['accountname'], ENT_QUOTES,'UTF-8'false)  . '</option>';
        }
    }
    echo 
'</select></td>'
https://www.linkedin.com/in/eclipsepaulbecker
Reply


Messages In This Thread
Prettier Grouped Dropdown Options? - by VortecCPI - 12-07-2018, 08:30 AM
RE: Prettier Grouped Dropdown Options? - by phil - 12-10-2018, 01:33 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)