This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > December 2005 > php to javascript convertion





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author php to javascript convertion
Pluda

2005-12-26, 10:33 pm

Hello,

I'm trying to make a nice blog header, but I now realise that blogspot.com
doesn't allow php...

I want to transform my nice PHP code to javascript... can this be done?

The goal is to have 7 td background images randomly positioned without
repetition...

here is my PHP code:

<?php
function random_array($min, $max, $num) {
$range = 1+$max-$min;
if($num > $range) {
return false;
}
$ret = Array();
while(count($ret) < $num) {
$a = "1";
do {
$a = rand($min, $max);
} while(in_array( $a, $ret));
$ret[] = $a;
}
return $ret;
}
$_SESSION['pix_array'] = random_array(1, 7, 7);
$locpic = $_SESSION['pix_array'];
?>

Thanks!

SnakEyez

2005-12-27, 3:30 am

See here is the dilemma, yes most PHP code can be transferred to Javascript in
a matter of speaking. Technically the easiest convert would be if you could
run JSP pages on your server because otherwise there is not much of a way to
convert items like sessions directly into javascript that I am aware of. The
rest of the code isn't too much of a problem, just some minor syntax changes at
most.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews