Problem with servo (my code)

Hello guys i am new in the world of arduino.
so i have look some examples and i start programming my ideas
(maybe my ideas are already in forum because they are simple)
so i try to connect 2 buttons in my arduino. that i want is, when i press the first button the servo will go from 0 ->180 and when i press the other button the servo will go from 180->0
i have write my code but only the first button works.
here is my code

#include <Servo.h>

Servo myservo; //
//

int pos = 180; //

int buttonState1 = 0;
int buttonState2 = 0;

void setup()
{
myservo.attach(9); //
pinMode(8,INPUT);
pinMode(2,INPUT);

}

void loop()

{ buttonState2 = digitalRead(8 );
buttonState1 = digitalRead(2);

if (buttonState1 == HIGH)

for(pos = 0; pos < 180; pos += 1) //
{ //
myservo.write(pos); //
delay(20); //

}
else (pos=180
);

if (buttonState2 == HIGH)

for(pos = 180; pos > 180; pos -= 1) //
{ //
myservo.write(pos); //
delay(20); //

}
else (pos=180
);
}

as i say i am new in arduino and i dont know many commands.
any idea what i make wrong ?

You need to use the # button to insert code properly BTW:

  for(pos = 180; pos > 180; pos -= 1)  //

How can that loop work - it loops while pos is greater than 180, pos is
never greater than 180.

Lots of odd style in that code, such as:

  if (buttonState1 == HIGH)
   
  for(pos = 0; pos < 180; pos += 1)  //
  {                                  //
    myservo.write(pos);              // 
    delay(20);                       //
   
  }
  else (pos=180
  );

Which would be normally (and more maintainably) coded as

  if (buttonState1 == HIGH)
  {
    for(pos = 0 ; pos < 180 ; pos += 1)
    {
      myservo.write (pos); 
      delay (20); 
    }
  }
  else
  {
    pos = 180 ;
  }

IE always indent to reflect the nesting, always use { } for sub-statements that are more
than one line, using () instead of {} for a statement group isn't going to cut it except
by accident as here. Use whitespace liberally to make code readable - cramming
everything into one block without spaces is hard to read, hard to read = more bugs slip
by.

Basic servo two button code.

//zoomkat servo button test 12-29-2011
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }    
  
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
}