I edited my code, see below:
I am trying to do an array with the time enroute. $distance works properly.
Now "ete" is giving this result for each leg: NaN Hrs. NaN Mins.
I replaced distance with 1500 and it spit out a result. That leads me to believe this [new Array();] is the problem.
I did some more digging var distance = new Array(""); is giving me this result: 431,910,746,923 Does that mean the implode did not work?
<script type="text/javascript">
var distance = new Array(<?=implode(', ', $distance)?>);
function Aircraft() {
var mylist = document.getElementById("myList");
for(var i = 0; i < distance.length; i++) {
var hour = (Math.floor(1500 / mylist.options[mylist.selectedIndex].value));
var minute = Math.round((Math.round(1500 / mylist.options[mylist.selectedIndex].value) - hour) * 60);
document.getElementById("ete" + i).innerHTML = hour + " Hrs. " + minute + " Mins.";
}
}
</script>
We're getting closer I think...
$distance = array();
for($i = 0, $size = sizeof($Row1); $i < ($size - 1); ++$i){
$distance[$i] = ROUND((ACOS(SIN($Row2[$i][4] * PI() / 180) * SIN($Row1[$i][4] * PI() / 180) + COS($Row2[$i][4] * PI() / 180) * COS($Row1[$i][4] * PI() / 180) * COS(($Row2[$i][5] - $Row1[$i][5]) * PI() / 180)) * 180 / PI()) * 60 );
echo "<td width=100>" . $distance[$i] . " NM</td>";
echo "<td width=100><span id=\"ete" . $i . "\"></span></td>";
}
?>
<script type="text/javascript">
var distance = new Array(<?=implode(', ', $distance)?>);
function Aircraft() {
var mylist = document.getElementById("myList");
for(var i = 0; i < distance.length; i++) {
var hour = (Math.floor(distance / mylist.options[mylist.selectedIndex].value));
var minute = Math.round((Math.round(distance / mylist.options[mylist.selectedIndex].value) - hour) * 60);
document.getElementById("ete" + i).innerHTML = hour + " Hrs. " + minute + " Mins.";
}
}
Here is where Aircraft() is used:
<select id=\"myList\" style=\"width:150px;\" onchange=\"Aircraft()\">
<option>Select Aircraft</option>
<option value=\"300\">King Air 350</option>
<option value=\"450\">G-V</option>
<option value=\"470\">GLEX</option>
<option value=\"350\">Astra</option>
</select>