Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Radio Buttons ! HELP PLEASE!

Status
Not open for further replies.

dapoole

Programmer
Dec 22, 2004
16
0
0
GB
Can someone tell me how to use radio buttons: i.e. I have two radio buttons and when one is highlighted and a triggered button is pressed it executes one script but if the other radio button is choosen and the triggered button presssed a different script is executed.

For example: in a WHEN-RADIO-CHANGED trigger I have

begin
if :R_1 = true
then
select sysdate from dual;
else if :R_2 = true
then
select (sysdate +1) from dual
else dbms.out_put.put_line('Error');
end;

Note: R_1 and R_2 are the names of the radio buttons.

Thanks

David
 
You cant check for the names of the radio buttons, but you need to chack the name of the group.

eg you may have a radio group called RADIO_GROUP with 2 buttons R_1 and R_2. R_1 has the value 'Y' assigned to it, and R_2 has 'N'. The WHEN-RADIO-CHANGED trigger will look like this (I have added code for correct syntax in red):

Code:
begin 
    if :RADIO_GROUP = 'Y'
        then
        select sysdate [COLOR=red]into <your_variable>[/color] from dual;
    else if RADIO_GROUP = 'N'
        then 
        select (sysdate +1) [COLOR=red]into <your_variable>[/color] from dual[COLOR=red];[/color]
    else dbms.out_put.put_line('Error');
    [COLOR=red]end if;[/color]
end;
 
Thanks Lewisp. Is it possible to create a triggered button that executes the appropriate pl/sql based on which radio button is highlighted? So far I have:

BEGIN
IF :RG_1.R_1=1
THEN
select (sysdate +1) into :text_1 from dual;
select 'Tomorrows Date' into text_2 from dual;

ELSIF :RG_1.R_2=2
THEN
select (sysdate +2) into :text_1 from dual;

END IF;
END;

However I receive bind errors for 'RG_1.R1' and RG_1.R2'

Thanks
 
No you cant do it that way. You can only reference the radio group itself, as I have already given an example of. This is the only way it can be done.

Code:
BEGIN
    IF :RG_1=1 
      THEN
      select (sysdate +1) into :text_1 from dual;
      select 'Tomorrows Date' into text_2 from dual;
      
    ELSIF :RG_1=2        
        THEN
      select (sysdate +2) into :text_1 from dual;
      
    END IF;
END;
 
In addition to lewisp's solution you should consider removing the SELECT statements, they are unnecessary and degrade performance:
Code:
BEGIN
    IF :RG_1=1 
      THEN
      :text_1 := (sysdate +1);
      :text_2 := 'Tomorrows Date';
      
    ELSIF :RG_1=2        
      THEN
      :text_1 := (sysdate +2);
      [COLOR=red]:text_2 := 'Day after tomorrows';[/color]
      
    END IF;
END;


[sup]Beware of false knowledge; it is more dangerous than ignorance.[/sup][sup] ~George Bernard Shaw[/sup]
Systems Project Analyst/Custom Forms & PL/SQL - Oracle/Windows
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top