This discussion is archived
5 Replies Latest reply: May 5, 2012 8:32 AM by VC RSS

Highlight values in select list

691174 Newbie
Currently Being Moderated
I have a select list of a code which must display extra values. Ordinarily, I'd return only code values where the obsolete_ind = "N" and limit the selection to these codes, but when a record is displayed with a code made obsolete after the record was initially created, I MUST allow display extra values. Iif I don't, the first value in the select list defaults, and it appears that that is the current value, which is not true!
So, I "display extra values" but I want to prevent the record from being 'saved' using the now obsolete value. Of course, a validation will resolve that, but the user's not going to know which are the valid codes to select.
Can specific values be highlighted, in red or something? if the selectlist tag <option value=""> also had id="", a dynamic action code do this, but I don't see how to add that "id" to the option tag.
Any suggestions?
  • 1. Re: Highlight values in select list
    scott.wesley Guru
    Currently Being Moderated
    Some options that come to mind
    - use apex_item to construct your select list, using the cattributes parameter makes it easy to add any custom attributes to colour certain entries
    - Many times in the past I have seen old code values tagged with an asterisk, then users are educated to know that they are the older options, and validation (browser or on submit) enforces it.
    - Have a display-only field that shows the current value, and a select list that offers only the current options

    Scott
  • 2. Re: Highlight values in select list
    VC Guru
    Currently Being Moderated
    Hi,

    Firstly you need this kind html markup to render the custom select list
    <select>
    <option value="181">Text Messages (Translation)</option>
    <option value="281" style="color:darkred;" >Jeditable APEX Item</option>
    <option value="1">Floating Div Toolbar</option>
    <option value="41" style="color:darkred;" >Oracle Apex Map</option>
    <option value="101">SQL to Json using Ajax</option>
    <option value="81">Warn user before browser close</option>
    <option value="141">Search</option>
    <option value="201">Screen saver plugin</option>
    <option value="261">HTML5 Progress Tag</option>
    <option value="21">Textfields with clear option</option>
    <option value="121">Enable RESTful Access</option>
    </select>
    Now you can create a custom function that generates the above markup, The below example gives you an idea of how to create an geniric function or even an apex item plugin for your requirement.

    try this in SQL workshop > SQL commands
    declare
      l_column_value_list apex_plugin_util.t_column_value_list;
    begin
    -- get the data for given sql query
      l_column_value_list := apex_plugin_util.get_data(p_sql_statement    => *'select ename,empno from emp'*,
                                                       p_min_columns      => 2,
                                                       p_max_columns      => 2,
                                                       p_component_name   => 'test',
                                                       p_search_type      => apex_plugin_util.c_search_contains_case,
                                                       p_search_column_no => 1,
                                                       p_search_string    => 'a');
    
      sys.htp.p('<select>');
      for i in 1 .. l_column_value_list(1).count loop
        sys.htp.p('<option value="' || sys.htf.escape_sc(l_column_value_list(2) (i)) || -- display column
                  '"'||case when upper(sys.htf.escape_sc(l_column_value_list(1) (i))) like '%APEX%' then ' style="color:darkred;" ' end||'>' || sys.htf.escape_sc(l_column_value_list(1) (i)) || -- return column
                  '</option>');
      end loop;
      sys.htp.p('</select>');
    end;
  • 3. Re: Highlight values in select list
    maceyah Journeyer
    Currently Being Moderated
    You can also just try something like this in a pl/sql type region at the bottom of your page. I'm no expert, but this works for me...
    htp.p('&lt;script language=JavaScript type=text/javascript>
    &lt;!-- ');
    for i in (select obsolete_ind, rownum r from my_lst ...) loop
      if obsolete_ind = 'N' then
        htp.p('$x("P10_MYLST")['||i.r||'].style.backgroundColor = "#E3E3E3";');
      end if;
    end loop;
    htp.p('
    //-->
    &lt;/script>');
    fixed typo May 4, 2012 2:10 PM
  • 4. Re: Highlight values in select list
    691174 Newbie
    Currently Being Moderated
    Thanks everyone! I have scenarios where all your ideas can be useful. Much appreciated.
  • 5. Re: Highlight values in select list
    VC Guru
    Currently Being Moderated
    Please mark the correct answer, so that other can benefit by this thread.


    Cheers

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points