...

View Full Version : Java to PHP



digic25
04-27-2006, 02:24 PM
Can anyone help me convert this small script to php. Any help is greatly appreciated!


<html>
<head>
<script type="text/javascript">
function isEven_Odd() {
for(i=0;i<=100;i++) {
var value = Math.random()*100; //generates a random number between 1 and
100.
value = Math.floor(value); //converts value to a whole number.
if (value%2 == 0){
n_even = value;
}else{
n_odd = value;
}
}
document.write(n_even + " " +"is an even number."+"<br>");
document.write(n_odd + " " +"is an odd number.");
}
</script>
</head>
<body>
<script type="text/javascript">

isEven_Odd();

</script>
</body>
</html>


Thanks
Tom

NancyJ
04-27-2006, 02:46 PM
<html>
<head>
<?
function isEven_Odd() {
for($i=0;$i<=100;$i++) {
$value = rand(1, 100);

if ($value%2 == 0){
$n_even = $value;
}else{
$n_odd = $value;
}
}
echo "$n_even is an even number.<br>";
echo "$n_odd is an odd number.<br>";
}
?>
</script>
</head>
<body>


<?=isEven_Odd();?>


</body>
</html>

digic25
04-27-2006, 03:25 PM
Thanks Nancy :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum