Adding Checkboxes To Report Rows Using HTML DB

March 31st, 2004 by Mark Rittman

A colleague and I were working today on an HTML DB application that displayed
a table of customer records. What we needed to do next was to put a checkbox
beside each customer record, so that we could select one or more of them for
subsequent processing.

Having looked through the HTML DB Forum, I came across
this posting that
referred to a
‘howto’ document available on OTN.
It’s actually quite simple:

  1. Go to the page that holds the report, and navigate to the region that
    contains the report.
  2. Bring up the SQL for the report query, and add an additional column:

    htmldb_item.checkbox(1,return_value)
    label



    HTMLDB_ITEM is a built-in package with HTML DB that can be used to
    generate certain form elements on the fly. In this case, it’s being used to insert a
    checkbox into our report, with a table column being nominated to be the return
    value (return_value) and a column alias (label) which is used
    for the column header in the report.

In our case, our amended SQL statement now read:

select id,
       serial,
       brand,
       model,
       cpu_type,
       cpu_speed,
       purchase_price,
       purchase_date,
       htmldb_item.checkbox(1,id) process

from   hardware

  1. Add a button into your region, call it something like ‘PROCESS’.
     
  2. Behind the scenes, HTML DB sets up a global package array with
    the name g_fxx, where xx is the first parameter
    (1 in the above case) passed to the HTMDB_ITEM.checkbox routine, and populates
    the array with the column values selected as specified in the second
    parameter.

    To process each row, add an ‘on submit’ process on the same page that is
    conditional on the ‘Process’ button being pressed, and add the following code
    to the process:

    for i in 1..htmldb_application.g_f01.count
    loop
       order.process(htmldb_application.g_f01(i));
    end loop;

    And retrieve the array values sequentially to process your records.
     

  3. Run your page, and you should see something like this

For a more detailed explanation, plus instructions on how create single and
multi-value checkboxes on a form, check out the
"Working with Check Boxes"
guide on OTN. Whilst you’re there,
check out the rest of the HTML DB Howto’s, including

Comments are closed.