Re: Use of check-box in HTML->SQL

From: Bob Krause <rjkrause_at_ix.netcom.com>
Date: 1996/12/06
Message-ID: <5899a9$p11_at_dfw-ixnews2.ix.netcom.com>#1/1


ika-team19_at_t-online.de (Janke & Kunkel GmbH u.CoKG, IKA Gruppe 19.) wrote:

>Hello,
 

>I work with DB 7.3 and Web-Server 2.0 under Windows NT. My problem is,
>that I will allow the user to mark several positions in an HTML-Page.
>That will I do with the Checkbuttons.
 

><input type=checkbox name="test" value="1"> Position 1
><input type=checkbox name="test" value="2"> Position 2
><input type=checkbox name="test" value="3"> Position 3
 

>The result is such as:
>TEST:
> 1
> 2
 

>Now my question. I will handle the choosing with an stored procedure.
>How must I declare the variable? When I use varchar2 or long I will
>get the first row. In this example: 1. The other row(s) are not
>available. What must I do?
>Please email me the answer. Thank you for help.
 

>kind reguard
 

>Frank Sommerfeld

This is how I handle checkboxes:

I create a defined datatype of "is table of varchar2(30) by binary_integer" to hold the values from the html page. Then I can loop my way through the values and process the values and perform the valid action. The html code must use a hidden data type of the same name as the checkbox. This will allow your PL/SQL procedure not to error out if no checkboxes are selected.

In my stored procedure spec:

        type checkbox_arr is table of varchar2(30) index by binary_integer;

            procedure read_checkbox(likes in checkbox_arr);

In my stored procedure body:

           procedure read_checkbox(likes in checkbox_arr)
	col_counter 	number := 0;
             pref  varchar2(1) := '';
           is
           begin
               col_counter := 2;
               loop 
                 pref := likes(col_counter);
	    if pref = '1' then
	  	........
	    elsif pref = '2' then
                            ........
                  else
                           ........
                 end if;
                 col_counter := col_counter + 1;
              end loop;
          exception
	when other then
		null;
         end read_checkbox;

In my html:

  <input type="hidden" name="likes" value="0">>
  <input type="checkbox" name="likes" value="1">Stout
  <input type="checkbox" name="likes" value="2">IPA
  <input type="checkbox" name="likes" value="3">Porter

This is a quick example that should give you the basic idea on how to work with the checkbox. Please excuse the lack of proper variable naming and the other stuff that should be in proper code. If you have any questions let me know. I am writing a commercial web site that is using WebServer ver 2.0 and Oracle 7.3 with dynamic pages and static pages.

Bob Krause
Software Engineer
Select Technologies Corp
e-mail: BobK_at_selectcorp.com
url: www.ticketslive.com Received on Fri Dec 06 1996 - 00:00:00 CET

Original text of this message