<html>

<script language=javascript>
function test_rendezo() {
    if(isNaN(document.rendezo.num.value) ||
       isNaN(document.rendezo.max.value) ||
       document.rendezo.num.value.length==0 ||
       document.rendezo.max.value.length==0) {
        alert("Mindket mezot ki kell tolteni es belejuk szamot kell irni!");
        return false;
    }
    document.rendezo.submit();
}
</script>

<body>

<?
if(!isset($num)) $num=20;
if(!isset(
$max)) $max=200;
?>

<form action=rendezo_form_js.php method=post name=rendezo>
num: <input type=text name=num value=<? echo $num; ?>><br>
max: <input type=text name=max value=<? echo $max; ?>><br>
<input type=submit value="Rendezz!" onclick="test_rendezo();return false;">
</form>

<table border=1 cellpadding=10><tr><td>
<font size=1><strong>
<?
for($i=0;$i<$num;$i++) {
    
$szamok[$i]=rand(0,$max);
    echo
$szamok[$i]."<BR>";
}
?>
<strong></font>
</td><td>
<font size=1><strong>
<?
for($i=sizeof($szamok)-1;$i>=0;$i--) {
    for(
$j=0;$j<=$i-1;$j++) {
        if(
$szamok[$j]>$szamok[$j+1]) { //csere
            
$temp=$szamok[$j];
            
$szamok[$j]=$szamok[$j+1];
            
$szamok[$j+1]=$temp;
        }
    }
}

for(
$i=0;$i<$num;$i++) {
    echo
$szamok[$i]."<BR>";
}
?>
<strong></font>
</td></tr></table>
</body></html>