Validation script on dropdown list field depended on other dropdown list

Hi, anyone can help me to make this happen? field#1 dropdown list is group like (Fruit) and field#2 dropdown list is type of fruit. I have many pages kind of fruit and I want to select feild#1 dropdown list it show kind of field #2. I tried many time but it seem error while we select group field#1 again it only go to page.
I tried following code from peoeple here in validation field#2 in Run Custom validation script as following:
if(event.value == "apple") this.pageNum = 1;
else if(event.value == "banana") this.pageNum = 2;
any Error in above scrip? Or any suggestion beside make validation script?
