<?php
if (isset($_POST['AddMultiple']))
{
  $value=$_POST['destination']+1;
}
else if ( (isset($_POST['Remove'])) && ($_POST['destination']>1))
{
  $value=$_POST['destination']-1;
}
else
{
  $value =1;
}
?>

 <input name="destination" type="hidden" value="<?php echo $value?>"/>


 <br />

<?php
function createInput($name, $value, $type)
{
	return "<input type=\"{$type}\" class=\"ajax\" name=\"{$name}\" value=\"{$value}\"/>";
}

function make_form($i_text,$val) {
//print_r($val);
$form = null;
$text = 'destination';
for($i = 1; $i <= $i_text; $i++)
{
    $form .= "<label><br /> Destination #" .$i. " city or IATA airport code<br />" ;
    $input = createInput($text.$i, $val[$text.$i], $text);
	$form .= $input."<br/></label>\n";
}

return $form;
}


echo make_form($value,$_POST);
?>
