If, elseIf, else statement block.

How would you test whether a radiobutton is selected or not?
if ( lineButton.Selected == true ){ 
s[ 0 ].move( move, move );;
else {
System.out.println("wasn't selected");
Keeps saying cannot find symbol - variable lineButton.
My best guess. If anyone could point out how to access the state of the button for using in this if, I would appreciate it.

i think i understand what is meant by the code you posted. It asks if the radiobutton is selected, and if so, then performs the statements.
I tried to use it, hopefully properly but still get the same error.
Here is the code:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import javax.swing.*;
public class Ch09Sample extends Applet implements ActionListener
    // Members
    private Button moveButton = new Button( "Move" );
    private TextField moveText = new TextField( "5" );
    private TextField moveText2 = new TextField( "5" );
    private int move = 0;
    private Shape [] s = new Shape[ 4 ];;
    private MyCanvas canvas = new MyCanvas();
    static String lineString = "Line";
    static String rectangleString = "Rectangle";
    static String circleString = "Circle";
    static String ovalString = "Oval";
    // An inner class
    class MyCanvas extends Canvas
        public void paint(Graphics g)
            for( int k = 0; k < s.length; k++ )
                s[ k ].draw( g );
    public void init()
        // Construct the shapes
        s[0] = new Line( 50, 80, 100, 110, Color.red ); 
        s[1] = new Circle( new Point( 30, 180 ), 20, Color.green );
        s[2] = new Oval( new Point( 150, 50 ), Color.blue );
        //s[3] = new Rectangle( );
        // Set the background color
        this.setBackground( Color.white );
        // Create the user interface
        Panel p1 = new Panel();
        p1.setLayout( new FlowLayout() );
        p1.setBackground( Color.white );
        Label label1 = new Label( "Moves in X:" );
        p1.add( label1 );
        p1.add( moveText );
        Label label2 = new Label( "Moves in Y:" );
        p1.add( label2 );
        p1.add( moveText2 );
        p1.add( moveButton );
        JRadioButton lineButton = new JRadioButton(lineString);
        lineButton.setMnemonic(KeyEvent.VK_B);
        lineButton.setActionCommand(lineString);
        lineButton.setSelected(true);
        JRadioButton rectangleButton = new JRadioButton(rectangleString);
        rectangleButton.setMnemonic(KeyEvent.VK_C);
        rectangleButton.setActionCommand(rectangleString);
        JRadioButton circleButton = new JRadioButton(circleString);
        circleButton.setMnemonic(KeyEvent.VK_D);
        circleButton.setActionCommand(circleString);
        JRadioButton ovalButton = new JRadioButton(ovalString);
        ovalButton.setMnemonic(KeyEvent.VK_R);
        ovalButton.setActionCommand(ovalString);
        ButtonGroup group = new ButtonGroup();
        group.add(lineButton);
        group.add(rectangleButton);
        group.add(circleButton);
        group.add(ovalButton);
        moveButton.addActionListener( this );
        lineButton.addActionListener(this);
        rectangleButton.addActionListener(this);
        circleButton.addActionListener(this);
        ovalButton.addActionListener(this);
        p1.add( lineButton );
        p1.add( rectangleButton );
        p1.add( circleButton );
        p1.add( ovalButton );
        setLayout( new BorderLayout() );
        add( "North", p1 );
        add( "Center", canvas );
        // An instance method
    public void moveDraw()
        // Get the user's input
        move = Integer.parseInt( moveText.getText() ); 
        // Move the shapes polymorphically
        for ( int k= 0; k < s.length; k++ ) 
            s[ k ].move( move, move );  
       if(lineButton.isSelected()) {
          s[ 0 ].move( move, move );;
          } else {
            System.out.println("wasn't selected");
        // Repaint the canvas
        canvas.repaint();
    public void actionPerformed( ActionEvent e )
        // Move the shapes and repaint the canvas
        moveDraw();
}

Similar Messages

  • If-elseif-else statement

    Hi,
    I am trying to write a if statement within a JSP page. I have some images stored in the database. Some of the entries does not have images. What I want to do is, if the entry did not match the string images then I want it to do nothing and if it is null then I want it to do nothing, else I would like to show the image. How would I write this code? The following is that I have gotten right now...
    <% if (rs.getString("image")==("images/untitled.gif") %>
    here I want it to do nothing...
    <% else if (rs.getString("image")=null)%>
    don't show anything again..
    <% else %> now is the change to show the image
    <IMG SRC="(rs.getString("image"))" >
    <% } %>
    How do I say to do nothing. I don't want it to do a out println.. but if I leave it blank the error message is 'else' without 'if'
    Any suggestions as to show nothing is the image does not exist? Thanks for all the commnents!

    I came up with a solution similar to yoda's:
    <% String imagePath = rs.getString("image");
       if ( imagePath != null && imagePath.equals("images/untitled.gif") )
       { %>
           <img src="<%= imagePath %>"> 
    <% } %>However, I don't quite understand your reply:
    I am still showing the boxes that are null without an imageAre you saying that if the image path is null you want an image displayed or not?
    --Nicole                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • If elseif else echo statement with radio buttons

    Hi everyone  Please help me out here.  I have a standard php file with 4 groups of questions (radio groups). The user must answer "yes" to ALL 4 questions where after "You Qualify" will echo on the same page.  If any of the questions are answered "No" to, then "you do not qualify" must echo on the same page. If no answer is selected - then no echo  This sounds like a simple if elseif else  statement, but for some reason I just cant get it right.  Could anyone please help me out with this?  Herewith code that I have tried:
    Do you like apples?        Yes           No 
    Do you like oranges?
            Yes           No 
    Do you like pears?
         Yes      No
    Do you like lemons?
         Yes      No

    <?php
    if ($a > $b) {
        echo "a is bigger than b";
    } elseif ($a == $b) {
        echo "a is equal to b";
    } else {
        echo "a is smaller than b";
    ?>

  • If-elseif-else

    Hi
    I have a trigger which had just if-else in it. Due to change in business requirement I had to re develop it and I decided to use if-elseif-else statement. I am getting the following error
    47/9    PLS-00103: Encountered the symbol "C_OPSHE" when expecting one of the following:
              . ( * @ % & = - + < / > at in is mod remainder not rem then
              <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_
              LIKE4_ LIKEC_ between || multiset member SUBMULTISET_
              The symbol "then" was substituted for "C_OPSHE" to continue.
    78/1    PLS-00103: Encountered the symbol "ELSE" when expecting one of the following:
              begin case declare end exit for goto if loop mod null pragma
              raise return select update while with <an identifier>
              <a double-quoted delimited-identifier> <a bind variable> <<
              close current delete fetch lock insert open rollback
              savepoint set sql execute commit forall merge pipe
    83/1    PLS-00103: Encountered the symbol "EXCEPTION"
    85/4    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
              end not pragma final instantiable order overriding static
              member constructor map Can some one help me please where I am getting it wrong:
    My trigger is as follows
    DECLARE
    crt_keyholder CLOB;
    addto varchar2(100);
    crt_key varchar2(75);
    issue varchar2(75);
    del_key varchar2(75);
    CURSOR c_opsHE IS
    SELECT pu.person_code FROM people_units pu        
    INNER JOIN unit_instances ui       
    ON pu.unit_instance_code = ui.fes_unit_instance_code       
    WHERE pu.unit_type = 'R'       
    AND pu.progress_status ='A'        
    AND pu.calocc_code LIKE '%12/13%'       
    AND (pu.unit_instance_code LIKE 'Z%' OR pu.unit_instance_code LIKE 'V%')       
    AND pu.unit_instance_code  NOT LIKE 'ZX%'     
    AND ui.fes_source_finance = 'HEFCE';      
    CURSOR c_opsFE IS
    SELECT pu.person_code FROM people_units pu
    INNER JOIN unit_instances ui
    ON pu.unit_instance_code = ui.fes_unit_instance_code
    WHERE pu.unit_type = 'R'
    AND pu.progress_status ='A'
    AND pu.calocc_code LIKE '%12/13%'
    AND (pu.unit_instance_code LIKE 'Z%' OR pu.unit_instance_code LIKE 'V%')
    AND pu.unit_instance_code  NOT LIKE 'ZX%'
    AND ui.fes_source_finance <> 'HEFCE';
    v_recOpsFE PEOPLE.PERSON_CODE%TYPE;
    v_recOpsHE PEOPLE.PERSON_CODE%TYPE;
    BEGIN
    if :new.fes_user_29 is not null then
        if :new.fes_staff_code is not null and :new.staff_user_4 = 'Y' then   
    crt_keyholder:= 'create keyholder'||' ' ||'"'|| :new.person_code||'"'||' '|| 'longname = "' ||:new.forename ||' '||:new.surname||'"'||' '||'comment = ""'||' '||'info1 = ""'||' '|| 'info2 ='||' '||'"'||:new.fes_staff_code||'"'||' '||'info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
    addto:= 'addtocommunity keyholder'||' '||'"'|| :new.person_code ||'"'||' community = "Staff" defaultgroups = "Yes";';
    crt_key:= 'create key'||' '||:new.fes_user_29||' box = '||'"General Use"'||' '||'technology = "Magnetic";';
    issue:= 'issue key '||:new.fes_user_29||' '||'technology = "Magnetic" keyholder ='||' '||'"'||:new.person_code||'";';
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_keyholder,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',addto,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_key,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',issue,0,'');
      else if
      OPEN  c_opsHE;
      FETCH c_opsHE INTO v_recOpsHE;
      IF c_opsHE%FOUND THEN
      crt_keyholder:= 'create keyholder'||' ' ||'"'|| :new.person_code||'"'||' '|| 'longname = "' ||:new.forename ||' '||:new.surname||'"'||' '||'comment = ""' ||' ' ||'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
    addto:= 'addtocommunity keyholder'||' '||'"'|| :new.person_code ||'"'||' community = "HEStudents" defaultgroups = "Yes";';
      crt_key:= 'create key'||' '||:new.fes_user_29||' box = '||'"General Use"'||' '||'technology = "Magnetic";';
      issue:= 'issue key '||:new.fes_user_29||' '||'technology = "Magnetic" keyholder ='||' '||'"'||:new.person_code||'";';
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_keyholder,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',addto,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_key,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',issue,0,'');
         end if;
         CLOSE c_opsHE;
      else 
      OPEN  c_opsFE;
      FETCH c_opsFE INTO v_recOpsFE;
      IF c_opsFE%FOUND THEN
      crt_keyholder:= 'create keyholder'||' ' ||'"'|| :new.person_code||'"'||' '|| 'longname = "' ||:new.forename ||' '||:new.surname||'"'||' '||'comment = ""' ||' ' ||'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
    addto:= 'addtocommunity keyholder'||' '||'"'|| :new.person_code ||'"'||' community = "FEStudents" defaultgroups  = "Yes";';
    crt_key:= 'create key'||' '||:new.fes_user_29||' box = '||'"General Use"'||' '||'technology = "Magnetic";';
    issue:= 'issue key '||:new.fes_user_29||' '||'technology = "Magnetic" keyholder ='||' '||'"'||:new.person_code||'";';
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_keyholder,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',addto,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',crt_key,0,'');
        insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',issue,0,'');
        end if;
         CLOSE c_opsFE; 
      end if;
    else
    del_key:= 'delete key'||' '||:old.fes_user_29||' '||'technology = "Magnetic"'||';';
    insert into ug_command values (UG_SEQUENCE.nextval,'ORACLE',del_key,0,'');
    end if;
    EXCEPTION
        WHEN others THEN Raise;
    END;

    For better readability, I formatted your code.. please check what should be there in place of (0=0)..
    DECLARE
       crt_keyholder   CLOB;
       addto           VARCHAR2 (100);
       crt_key         VARCHAR2 (75);
       issue           VARCHAR2 (75);
       del_key         VARCHAR2 (75);
       CURSOR c_opsHE IS
          SELECT pu.person_code
            FROM    people_units pu
                 INNER JOIN
                    unit_instances ui
                 ON pu.unit_instance_code = ui.fes_unit_instance_code
           WHERE     pu.unit_type = 'R'
                 AND pu.progress_status = 'A'
                 AND pu.calocc_code LIKE '%12/13%'
                 AND (pu.unit_instance_code LIKE 'Z%'
                      OR pu.unit_instance_code LIKE 'V%')
                 AND pu.unit_instance_code NOT LIKE 'ZX%'
                 AND ui.fes_source_finance = 'HEFCE';
       CURSOR c_opsFE IS
          SELECT pu.person_code
            FROM    people_units pu
                 INNER JOIN
                    unit_instances ui
                 ON pu.unit_instance_code = ui.fes_unit_instance_code
           WHERE     pu.unit_type = 'R'
                 AND pu.progress_status = 'A'
                 AND pu.calocc_code LIKE '%12/13%'
                 AND (pu.unit_instance_code LIKE 'Z%'
                      OR pu.unit_instance_code LIKE 'V%')
                 AND pu.unit_instance_code NOT LIKE 'ZX%'
                 AND ui.fes_source_finance != 'HEFCE';
       v_recOpsFE      PEOPLE.PERSON_CODE%TYPE;
       v_recOpsHE      PEOPLE.PERSON_CODE%TYPE;
    BEGIN
       IF :new.fes_user_29 IS NOT NULL THEN
          IF :new.fes_staff_code IS NOT NULL AND :new.staff_user_4 = 'Y' THEN
             crt_keyholder :=
                   'create keyholder'
                || ' '
                || '"'
                || :new.person_code
                || '"'
                || ' '
                || 'longname = "'
                || :new.forename
                || ' '
                || :new.surname
                || '"'
                || ' '
                || 'comment = ""'
                || ' '
                || 'info1 = ""'
                || ' '
                || 'info2 ='
                || ' '
                || '"'
                || :new.fes_staff_code
                || '"'
                || ' '
                || 'info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
             addto :=
                   'addtocommunity keyholder'
                || ' '
                || '"'
                || :new.person_code
                || '"'
                || ' community = "Staff" defaultgroups = "Yes";';
             crt_key :=
                   'create key'
                || ' '
                || :new.fes_user_29
                || ' box = '
                || '"General Use"'
                || ' '
                || 'technology = "Magnetic";';
             issue :=
                   'issue key '
                || :new.fes_user_29
                || ' '
                || 'technology = "Magnetic" keyholder ='
                || ' '
                || '"'
                || :new.person_code
                || '";';
             INSERT INTO ug_command
                  VALUES (UG_SEQUENCE.NEXTVAL,
                          'ORACLE',
                          crt_keyholder,
                          0,
             INSERT INTO ug_command
                  VALUES (UG_SEQUENCE.NEXTVAL,
                          'ORACLE',
                          addto,
                          0,
             INSERT INTO ug_command
                  VALUES (UG_SEQUENCE.NEXTVAL,
                          'ORACLE',
                          crt_key,
                          0,
             INSERT INTO ug_command
                  VALUES (UG_SEQUENCE.NEXTVAL,
                          'ORACLE',
                          issue,
                          0,
          ELSIF (0 = 0) THEN
             OPEN c_opsHE;
             FETCH c_opsHE INTO v_recOpsHE;
             IF c_opsHE%FOUND THEN
                crt_keyholder :=
                      'create keyholder'
                   || ' '
                   || '"'
                   || :new.person_code
                   || '"'
                   || ' '
                   || 'longname = "'
                   || :new.forename
                   || ' '
                   || :new.surname
                   || '"'
                   || ' '
                   || 'comment = ""'
                   || ' '
                   || 'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
                addto :=
                      'addtocommunity keyholder'
                   || ' '
                   || '"'
                   || :new.person_code
                   || '"'
                   || ' community = "HEStudents" defaultgroups = "Yes";';
                crt_key :=
                      'create key'
                   || ' '
                   || :new.fes_user_29
                   || ' box = '
                   || '"General Use"'
                   || ' '
                   || 'technology = "Magnetic";';
                issue :=
                      'issue key '
                   || :new.fes_user_29
                   || ' '
                   || 'technology = "Magnetic" keyholder ='
                   || ' '
                   || '"'
                   || :new.person_code
                   || '";';
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             crt_keyholder,
                             0,
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             addto,
                             0,
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             crt_key,
                             0,
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             issue,
                             0,
             END IF;
             CLOSE c_opsHE;
          ELSE
             OPEN c_opsFE;
             FETCH c_opsFE INTO v_recOpsFE;
             IF c_opsFE%FOUND THEN
                crt_keyholder :=
                      'create keyholder'
                   || ' '
                   || '"'
                   || :new.person_code
                   || '"'
                   || ' '
                   || 'longname = "'
                   || :new.forename
                   || ' '
                   || :new.surname
                   || '"'
                   || ' '
                   || 'comment = ""'
                   || ' '
                   || 'info1 = "" info2 = "" info3 = "" info4 = "" info5 = "" info6 = "" info7 = "" info8 = "" info9 = "" info10 = "" info11 = "" info12 = "" info13 = "" info14 = "" info15 = "" info16 = "";';
                addto :=
                      'addtocommunity keyholder'
                   || ' '
                   || '"'
                   || :new.person_code
                   || '"'
                   || ' community = "FEStudents" defaultgroups  = "Yes";';
                crt_key :=
                      'create key'
                   || ' '
                   || :new.fes_user_29
                   || ' box = '
                   || '"General Use"'
                   || ' '
                   || 'technology = "Magnetic";';
                issue :=
                      'issue key '
                   || :new.fes_user_29
                   || ' '
                   || 'technology = "Magnetic" keyholder ='
                   || ' '
                   || '"'
                   || :new.person_code
                   || '";';
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             crt_keyholder,
                             0,
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             addto,
                             0,
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             crt_key,
                             0,
                INSERT INTO ug_command
                     VALUES (UG_SEQUENCE.NEXTVAL,
                             'ORACLE',
                             issue,
                             0,
             END IF;
             CLOSE c_opsFE;
          END IF;
       ELSE
          del_key :=
                'delete key'
             || ' '
             || :old.fes_user_29
             || ' '
             || 'technology = "Magnetic"'
             || ';';
          INSERT INTO ug_command
               VALUES (UG_SEQUENCE.NEXTVAL,
                       'ORACLE',
                       del_key,
                       0,
       END IF;
    EXCEPTION
       WHEN OTHERS THEN
          RAISE;
    END;Cheers,
    Manik

  • Best way to test each if else statement

    Hey everyone I have a few scripts that have many different if ,elseif, else blocks. The problem is that they are hard to test and some are rarely triggered. However I need to check to make sure the contents triggered by one of the statements works. I know
    there is a whatif switch but from my understanding it is only used for specific commands and doesn't actually trigger them. 
    So is there some way to debug them or force the script to meet a condition of an if statement?
    Thanks for any help!!

    Hi,
    I generally put a Write-Output in each branch that will tell me where I am. Here's an example:
    $trigger = 1
    If ($trigger -eq 1) {
    Write-Output 'Found #1'
    } ElseIf ($trigger -eq 2) {
    Write-Output 'Found #2'
    } ElseIf ($trigger -eq 3) {
    Write-Output 'Found #3'
    } Else {
    Write-Output 'Found something else'
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Compilation error with simple if-else statement

    package chapterFive;
    * Author: Sarab
    * Filename: MainClass.java
    * Purpose: Try and get my mind around the concept of the selection
    * control structures and repetition statements
    class MainClass {
         public static void main(String [] args)
              // some variables and prompt for input
              java.util.Scanner scan = new java.util.Scanner(System.in);
              System.out.print("Please enter your name: ");
              String input = scan.nextLine();
              // some repetition statement, for loop
              if (input.equals("Sarab"));
                   System.out.println("Welcome Sarab!");
              else
                   System.out.println("You are in the else statement");
                   for(int sentinelValue; sentinelValue<5; sentinelValue++)
                        System.out.println("The following is the numbers 0-4"
                                  + " printed on separate lines: " + sentinelValue);
              System.out.println("This line will print regardless of whether you"
                        + " entered the if or the else portion of the selection"
                        + " statement.");
    }I am getting the following error:
    Exception in thread "main" java.lang.Error: Unresolved compilation problem:
         Syntax error on token "else", delete this token
         at chapterFive.MainClass.main(MainClass.java:26)What's the matter? This looked straight forward enough to me.

    if (input.equals("Sarab"));
    // is the same as
    if (input.equals("Sarab")) {}
    // so what you have amounts to this:
    if (input.equals("Sarab")) {}
      System.out.println("Welcome Sarab!");
    else { ... }You've got an if block that does nothing, then a block that always executes, calling println, and then your else. Since you have that block between if and else, the if has ended and it's not legal to use else.
    Get rid of the semicolon after if.

  • IF elseif else usage

    So, now I've been trying to learn If, elseif and else statements properly.  And I'm doing something wrong. 
    A guy told me his website would email specific people based on what zipcode they put in the contact form on his site.  I was wondering how he did it, so I tried to recreate something similar.
    Here is what I've done:
    1. I created a file called zipcodes.php
    2. In this file it has set every zipcode to a variable.  For instance:
    <?php
    $Nashville=("37010" or "37027" or "37040" or "37055" or "37152");
    ?>
    3.  I created a form with a field called 'zip'.
    4. I created a php file called phpmail.php to send this form.
    5. Right now, the top of this file looks like this:
    <?php
    include("zipcodes.php");
    $zip=$_POST["zip"];
    //NASHVILLE//
    if ($zip==$Nashville)
    $my_email = "[email protected]";
    //Knoxville//
    if ($zip==$Knoxville)
    $my_email = "[email protected]";
    //Huntsville//
    if ($zip==$Huntsville)
    $my_email = "[email protected]";
    ...etc.
    This doesn't work.  It sends them all to the last option which is texas or [email protected]
    Before I had the first if set to if and all the others set to elseif
    But that didn't work.  It sent all the emails to Nashville email I made.
    If statements must work though in this way.  Because if I have this:
    if ($zip==$Nashville)
    $my_email = "[email protected]";
         //Anything Else//
      else $my_email = "[email protected]";
    It works.  Meaning if a zipcode is in Nashville it goes to one email - and if it isn't in Nashville - it goes to hippityhoppity.
    Am I not getting something about all of this?  Thanks!

    Yeah I know.  I also wish it'd let me use PHP syntax instead of plain.  I think it'd make things easier to read.
    Here is the entire script.  It is made to work with any form with little regard for what the form has in it.  So long as there is an email field and a zip field.
    <?php
    include("zipcodes.php");
    $zip=$_POST["zip"];
              if (in_array($zip, $Nashville)) {
    $my_email = ".....";
              }elseif (in_array($zip, $Knoxville)) {
    $my_email = ".....";
              }elseif (in_array($zip, $Huntsville)) {
    $my_email = ".....";
              }elseif (in_array($zip, $Florida)) {
    $my_email = ".....";
              }elseif (in_array($zip, $Georgia)) {
    $my_email = ".....";
              }elseif (in_array($zip, $SouthCarolina)) {
    $my_email = ".....";
              }elseif (in_array($zip, $NorthCarolina)) {
    $my_email = ".....";
              }elseif (in_array($zip, $Pennsylvania)) {
    $my_email = ".....";
              }elseif (in_array($zip, $Maryland)) {
    $my_email = ".....";
               }elseif (in_array($zip, $Virginia)) {
    $my_email = ".....";
               }elseif (in_array($zip, $Texas)) {
    $my_email = ".....";
    } else { $my_email = ".....";
    $continue = "/";
    $errors = array();
    if(count($_COOKIE)){foreach(array_keys($_COOKIE) as $value){unset($_REQUEST[$value]);}}
    function recursive_array_check_header($element_value)
    global $set;
    if(!is_array($element_value)){if(preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc: )/i",$element_value)){$set = 1;}}
    else
    foreach($element_value as $value){if($set){break;} recursive_array_check_header($value);}
    recursive_array_check_header($_REQUEST);
    if($set){$errors[] = "You cannot send an email header";}
    unset($set);
    if(isset($_REQUEST['email']) && !empty($_REQUEST['email']))
    if(preg_match("/(%0A|%0D|\n+|\r+|:)/i",$_REQUEST['email'])){$errors[] = "Email address may not contain a new line or a colon";}
    $_REQUEST['email'] = trim($_REQUEST['email']);
    if(substr_count($_REQUEST['email'],"@") != 1 || stristr($_REQUEST['email']," ")){$errors[] = "Email address is invalid";}else{$exploded_email = explode("@",$_REQUEST['email']);if(empty($exploded_email[0]) || strlen($exploded_email[0]) > 64 || empty($exploded_email[1])){$errors[] = "Email address is invalid";}else{if(substr_count($exploded_email[1],".") == 0){$errors[] = "Email address is invalid";}else{$exploded_domain = explode(".",$exploded_email[1]);if(in_array("",$exploded_domain)){$errors[] = "Email address is invalid";}else{foreach($exploded_domain as $value){if(strlen($value) > 63 || !preg_match('/^[a-z0-9-]+$/i',$value)){$errors[] = "Email address is invalid"; break;}}}}}}
    if(!(isset($_SERVER['HTTP_REFERER']) && !empty($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST']))){$errors[] = "You must enable referrer logging to use the form";}
    function recursive_array_check_blank($element_value)
    global $set;
    if(!is_array($element_value)){if(!empty($element_value)){$set = 1;}}
    else
    foreach($element_value as $value){if($set){break;} recursive_array_check_blank($value);}
    recursive_array_check_blank($_REQUEST);
    if(!$set){$errors[] = "You cannot send a blank form";}
    unset($set);
    if(count($errors)){foreach($errors as $value){print "$value<br>";} exit;}
    if(!defined("PHP_EOL")){define("PHP_EOL", strtoupper(substr(PHP_OS,0,3) == "WIN") ? "\r\n" : "\n");}
    function build_message($request_input){if(!isset($message_output)){$message_output ="";}if(!is_array($request_input)){$message_output = $request_input;}else{foreach($request_input as $key => $value){if(!empty($value)){if(!is_numeric($key)){$message_output .= str_replace("_"," ",ucfirst($key)).": ".build_message($value).PHP_EOL.PHP_EOL;}else{$message_output .= build_message($value).", ";}}}}return rtrim($message_output,", ");}
    $message = build_message($_REQUEST);
    $message = $message . PHP_EOL.PHP_EOL."-- ".PHP_EOL."";
    $message = stripslashes($message);
    $subject = "FormToEmail Comments";
    $headers = "From: " . $_REQUEST['email'];
    mail($my_email,$subject,$message,$headers);
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Dreamweaver Tutorial - Contact Form</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body bgcolor="#ffffff" text="#000000">
    <div>
    <center>
    <b>Thank you <?php print stripslashes($_REQUEST['name']); ?></b>
    <br>Your message has been sent
    <p><a href="<?php print $continue; ?>">Click here to continue</a></p>
    </center>
    </div>
    </body>
    </html>

  • IF ELSE Statement in BEx Query based on the results

    Hi experts,
    I want to realize the following IF/ELSE statement in a BEx Query in respect to the result values
    If the result of KF1 equals 0, than set the KF2 to 0, Else (KF1 NE 0) show the value of KF2
    Background: I want to report the order backlog. In the example above we have an incoming order value of 23.700,80 EUR in periode 12.2013 and an turnover of 22.370,80 EUR in periode 01.2014. The order backlog in ST (KF1) is 1 ST (12.2013) - 1 ST (01.2014) = 0 ST. The order backlog in EUR (KF2) is 23.700,80 EUR (12.2013) - 22.370,80 EUR (01.2014) = 1.330 EUR. The Order and Invoice is finished, but we have an positive order backlog in EUR (reason: less turnover as incoming order).
    For this case I want to realize the IF/Else statement to check if the oder backlog in ST = 0, if yes, than set the order backlog in EUR also to 0.
    Any best practices?
    Many thanks and best regards,
    Michael

    Hi Suman,
    thanks aigain for your reply!
    I have tried your proposal before you have posted it.
    In my special case the following if/else statement works successfully:
    CKF = calculated key figure
    Formula1 = (CKF1 == 0) * 0 + (CKF1 <> 0) * CKF2
    In my case the CKF2 is the result value from "Incoming Order value" - "Turnover"
    So I had to define a separate Formula (1:1 equals to CKF2) and then I was able to set "*CKF2" in the statement.
    The statement CKF2 = (CKF1 == 0) * 0 + CKF2 is not possible (because it´s not possible to calculate from CKF2 itself).
    Now it works
    Best regards,
    Michael

  • If else statement

    hi everyone
    i need help
    I'm trying to make if else statement in the sqldeveloper query
    and my code us like ...
    IF CHARGE_PRICE BETWEEN 10000 AND 20000
    THEN
    charge_apartment(1,600);
    ELSIF CHARGE_PRICE BETWEEN 20000 AND 40000
    THEN
    charge_apartment(1,500);
    ELSIF CHARGE_PRICE > 40000
    THEN
    charge_apartment(1,900);
    ELSE
    charge_apartment(1,650);
    END IF;
    now the question is how do i cover that part of code so the sqldeveloper query will know that I'm talking about an Apartments table...?
    I dig around the net and so far all the info i got is relevant only for sql*Plus
    so...
    How can I do this at the query?
    thanks in advance
    Edited by: 885780 on Sep 16, 2011 4:04 PM
    Edited by: 885780 on Sep 16, 2011 4:05 PM

    I'll explain myself again more clearly
    if i', execute the command
    execute Charge_Apartment(1,600)
    so the right apartment is being charged with the right peice,
    But!
    if i'm execute
    CASE
    WHEN APARTMENT_SIZE < 10000 THEN Charge_Apartment(1,650);
    WHEN APARTMENT_SIZE < 20000 THEN Charge_Apartment(1,600);
    WHEN APARTMENT_SIZE < 40000 THEN Charge_Apartment(1,500);
    ELSE Charge_Apartment(1,900);
    END
    I'm crashing with
    Error starting at line 1 in command:
    CASE
    Error report:
    Unknown Command
    Error starting at line 2 in command:
    WHEN APARTMENT_SIZE < 10000 THEN Charge_Apartment(1,650)
    Error report:
    Unknown Command
    Error starting at line 3 in command:
    WHEN APARTMENT_SIZE < 20000 THEN Charge_Apartment(1,600)
    Error report:
    Unknown Command
    Error starting at line 4 in command:
    WHEN APARTMENT_SIZE < 40000 THEN Charge_Apartment(1,500)
    Error report:
    Unknown Command
    Error starting at line 5 in command:
    ELSE Charge_Apartment(1,900)
    Error report:
    Unknown Command
    Error starting at line 6 in command:
    END
    Error report:
    Unknown Command
    If someone can help me i'll be glad
    Thanks in advance 4 all of you who helped so far ...

  • Charactersitic values to be used in IFTHEN ELSE STATEMENT IN QUERY

    scenario: i need to use the characteristic values(not the attributes) to be used in an IF THEN ELSE STATEMENT in query. so i created a formula variable for the characteritic of processing type replacement path, replace with key.The values are not fetched in the result and is displayed as X.
    what should i replace with key,lable, constant or other options whereas  my requirement is the all the values present in the characteristc should be used.
    eg. if char name is xyz and has the values 1,2,3,4,5 till -
    20.
    then in a calculated key figure :(formulavariable =1)* kefig1keyfig2 +not(formulavariable =1)kef2keyfig3.
    this formula variable should have all the values of the characteristic values ie 1,2,3---20.
    2. how should i do get the values of characterstics values in the equation give me the steps in detail..
    3. i do not want to use the attributes, though i tried initally while creating the formual variable i replaced with attribute value, there is was an error and there were no reult.
    i tried to create char. variable  for the characteristic  of manual entr , not ready for input values and gave all the values 1,2,3 --20 as default values and then created formaul variable and repalce with the variable, however this characteristic variable is not at all displayed from the list of variables which will be displayed while creating the formula variable.
    help me out.
    Thanks

    hi srini,
    i have includedthe char in rows. i want you to explain in detail how to use these values in the if then else statement in query.
    i have created a calculated key figure 2= (formual variable =1 & keyfig a =0)* keyfig1kefig2 +not(formual variable =1 & keyfig a =0)keyfig2 *calculated keyfig1.
    so this formula variable of replacement path have ref. to then char. and with what value should it replace, key, name, external char or attribut etc so that i should get the values of the char from 1 to20.
    i donot to repalce with the attribute. i just want the char. values and not thier attributes (1. description 2. the second attribute has the values say abc1,efg2,ghi3 for respective charteristic values.
    ie
    char value               desc                 2nd attrib
    1                            hi                     abc1
    2                            bye                  defg2
    3                            ciao                  ghi3

  • IF ELSE statement / CMOD Code in BEX Query

    Hi
    I have a requirement in Inventory flow.
    Material stock value at the end of each quarter has to be calculator based on cycle count indicator. I have all the values on my cube.
    In the report, Calender year and quarter is on the selection screen.
    When user enters 2014 and Q2, Data for April, May and June are displaying on the report. But user want data only for June.
    At the end of quarter 2 is June, so he wants only Material stock value at the end of June.
    If a material stock level is changed in April and May and not changed in June, not data is available for June in my Cube.
    In this case for Quarter 2, if June data is missing, it has to look for May data. Even if MAY data is missing, it will have to look for April.
    Even if April data is missing, it will have to look for March data.
    The result should be
    Plant    Q1    Q2    Q3   Q4
    XYZ     100    100  100    100
    If there is no change to stock level in April, May & June - at the end of Quarter 2, the stock value should be 100 as it was in end of Q1.
    If no change was dont to stock level until December, the stock level should be 100.
    Is there a way out using IF ELSE statements or through CMOD customer exit.
    Regards,
    Elango Murgesan

    HI Elango,
    the user input on CALQuarter always would be Single value??or can we expect ranges as well?
    if single value,
    then we can achieve it by having one more dummy KF.
    lets say. user input is Q2. 
    -> in your dummy KF, restrict the Calquarter/Calmonth to last quarter(i.e Q1)using customer exit and make the logic as you said above(last value based on calmonth).(make this KF hidden, as this is not required to display)
    -> and in another KF restricted with Q2.Same logic, last value on Calmonth.((make this KF hidden, as this is not required to display)
    and now you have 2 KFs in your report.  So in a formula, you can have condition-> if Q2 KF is blank, then Q1KF, else Q2 KF.
    Hope you are getting my idea.. Please try this and let us know.
    ** if Q1 also null, then we can extend customer exit logic to may be last one year, and having last value on based on calendar month, we can still achieve i guess.
    Regards,
    Sakthi.

  • Looking for a best query for multiple IF Else statement in a single select

    Hi
    I want to run multiple IF Else statements in a single select SQL, each statement is one SQL operating on the same table, what is the best way to write this select SQL query ?
    If it is PL/SQL, when i get the result from the first IF statement I will skip the remaining execution, and so on... Can any one help me on this.
    Thanks in advance !!

    965818 wrote:
    I Apologize, the information i have given might not be enough.
    This is my scenario,
    I am selecting set of rows from the table for the employee id. After selecting those records,
    i need to go through the result list and check the condition 1, if it is met, i will return that employee record.
    If that condition 1 is not met, then i need to go through the condition 2. If that is met, i will return that record.
    Like wise, i have four conditions.
    I am trying to achieve this in a single sql. If i am not clear, please let me know.Not fully clear yet, but the picture is better already. The thing with SQL is that you should stop thinking procedurally. Instead think in data sets.
    For example if the task is:
    Find all managers that work in sales.
    Procedural thinking would work like this:
    pseudo code
    Loop over all employees that work in sales
       for each row
           check if it is a manager
               if manager
                  then return record
               else
                  do nothing
               end
    end loopThinking in datasets will result in a different logic
    pseudo code
    select all employees
    where department = SALES
    and job = MANAGERThis advantage here is that all the "Do nothing" loops are not needed. Those are already eliminated by the database.
    So what is needed to help you? Give the full picture. What is your task that you try to solve. From a business perspective.

  • How to use IF ELSE statement in one QUERY to MS ACCESS

    System.out.println("Enter Final Exam: ");
    int f = Integer.parseInt(input.readLine());
    command.executeUpdate("UPDATE Students SET Final_Exam='"+f+"',Raw_score=(QT+MT+Final_Exam)/3 WHERE stud_name='"+stdID+"'");
    command.executeUpdate("UPDATE Students SET Raw_score=(QT+MT+Final_Exam)/3 WHERE stud_ID='"+stdID+"'");
    if (rsf==100)
    command.executeUpdate("UPDATE Students SET Final_Grade=1.0 WHERE stud_ID='"+stdID+"'");
    else if(rsf < 100 && rsf > 90)
    command.executeUpdate("UPDATE Students SET Final_Grade=2.0 WHERE stud_ID='"+stdID+"'");
    else
    command.executeUpdate("UPDATE Students SET Final_Grade=5.0 WHERE stud_ID='"+stdID+"'");How can I shorten my code using a IF ELSE statement inside a single query or two? Or is it possible?
    Edited by: ivatanako on Sep 28, 2007 11:55 PM

    Sun has tutorial trail for JDBC, you might want to browse through that; you'll get more details and samples there than here. Here's the link to the section on PreparedStatement: http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • IF-ELSE statement in BI  Query

    Hi guys i have a requirement where in i have condition as mention below...
    If  say X=0 then Y=0  and
        if    X>0  then y=1
      where X  is  key figure value...to be compared ..
    can any one suggest me the logic as to how i need to design this in the query..any option of using IF-ELSE statement...
    an in the result if  Y=0 then i should show as a * (star)..how can we do this in the query?
    can any one suggest me a solution for this please..
    Rgds
    Shilpa

    shipa,
    please check these links
    [Defining Exceptions|http://help.sap.com/SAPHELP_NW04S/helpdata/EN/43/21b4cd14cd06f4e10000000a422035/frameset.htm]
    [Defining and Changing Exceptions|http://help.sap.com/saphelp_nw04/helpdata/EN/c2/f6843b49f6a40de10000000a11402f/content.htm]

  • If Then Else Statement in SAP R/3 BW

    Hi,
    Does anyone know how to create an If Then Else statement in BEX?
    Thanks,
    Mounika.

    Hi mounika,
    do this way
    If 'material number' > 0.
    rslt = 'enter into table'.
    else.
    rslt = 15.
    endif.
    A True condition always evaluates to 1, a False condition evaluates to 0.
    for more quieries in bw ..pls go through  the link
    http://sap.ittoolbox.com/groups/technical-functional/sap-bw
    pls reward if helps,
    regards.

Maybe you are looking for

  • How can I reduce the brightness of my screen?

    I installed WIndows 7 on my MAC and after installing the boot camp drivers, the screen went really bright. I reduced the brightness to the lowest setting on my keyboard, but it is still bright. The problem is not so much on the graphics, its more on

  • Best practice to initialize my instruments

    I wonder what is the best practice to initilize instruments on test stand. i have a vi that will ready a INI configuration file and map my instruments  and will output  a cluster(DMM, Scope, etc..) so when starting the sequence on pre UUT i will load

  • SOLUTION FOR 3110 RESTARTING!!

    Finaly I hawe hawe found the solution for restarting problem! 1.Format your memory card 2.Make shortcut on your mobile so u can access very fast to your media player 2.1. In SETTINGS/DISPLAY/ACTIVE STANDBY/ACTIVE STANDBY MODE (TURN ON)/PERSONALIZE VI

  • Add on xl reporter nit installing

    I installed sap b1 2007 pl 15 client on windows xp system (sql 2005 & office 2007). now whent i login sap, during installation of add on xl reporter, it gives error run time error '-2147417851 (80010105) method '' of object '' failed every thing is w

  • Discovering cubes using the API

    Question� I am interested in using the Oracle OLAP (Java) API to discover the cubes in a database. However, the �Developer�s Guide to the OLAP API� states the following on pages 38-39: Note that the OLAP metadata includes a cube object, which does no