Location: PHPKode > projects > PHPfaces - User Interface Framework > demo/getting_started/getstarted_events.php
<?php

	class on_country_change extends PSelectionEvent
	{
		function selectionChanged($ui, $form, $component, $index)
		{
			$country = $form->getComponent('country');
			$store = $form->getComponent('store');
	
			//$index = $country->getSelectionIndex();
			$value = $country->getValue($index);
	
			switch ($value)
			{
				case "ger":
					$store->importOptions(
						array(
							"Berlin"	=> "Berlin",
							"Hamburg"	=> "Hamburg",
							"Wuppertal"	=> "Wuppertal"
						)
					);
					break;
				case "eng":
					$store->importOptions(
						array(
							"London"		=> "London",
							"New Hampshire"	=> "New Hampshire",
							"Oxford"		=> "Oxford"
						)
					);
					break;
				case "us":
					$store->importOptions(
						array(
							"Las Vegas"	=> "Las Vegas",
							"New York"	=> "New York",
							"San Diego"	=> "San Diego"
						)
					);
			}
		}
	
		function getFile()
		{
			return __FILE__;
		}
	}
	
	class on_submit extends PActionEvent
	{
		function actionPerformed($ui, $form, $component)
		{
			$country = $form->getComponent('country');
			$store = $form->getComponent('store');
			$firstname = $form->getComponent('firstname');
			$name = $form->getComponent('name');
			$email = $form->getComponent('email');
	
			$text  = "$name, $firstname\n";
			$text .= "$email\n";
			$text .= "$country:$store";
	
			mail("hide@address.com",'mail from your contact form',$text);
		}
	
		function getFile()
		{
			return __FILE__;
		}
	}

?>
Return current item: PHPfaces - User Interface Framework