<?php function pre_hours(){ $f = $_POST['pre_hours']; return $f; } function pre_gpa(){ $f = $_POST['pre_gpa']; return $f; } function pre_sum(){ $f = pre_gpa() * pre_hours(); return $f; } function new_hours(){ if($_POST['mark1'] == 0 ){ $hour1 = 0; }else{ $hour1=$_POST['hours1'];} if($_POST['mark2'] == 0 ){ $hour2 = 0; }else{ $hour2=$_POST['hours2'];} if($_POST['mark3'] == 0 ){ $hour3 = 0; } else{ $hour3=$_POST['hours3'];} if($_POST['mark4'] == 0 ){ $hour4 = 0; } else{ $hour4=$_POST['hours4'];} if($_POST['mark5'] == 0 ){ $hour5 = 0; }else{ $hour5=$_POST['hours5'];} if($_POST['mark6'] == 0 ){ $hour6 = 0; }else{ $hour6=$_POST['hours6'];} if($_POST['mark7'] == 0 ){ $hour7 = 0; }else{ $hour7=$_POST['hours7'];} if($_POST['mark8'] == 0 ){ $hour8 = 0; }else{ $hour8=$_POST['hours8'];} $total = $hour1 + $hour2 + $hour3 + $hour4 + $hour5 + $hour6 + $hour7 + $hour8 ; return $total; } function new_sum(){ if($_POST['mark1'] == 0 ) $course1 = 0; else{ $hour1=$_POST['hours1']; $course1 = ($_POST['mark1']) * $hour1; } if($_POST['mark2'] == 0 ){ $course2 = 0; }else{ $hour2=$_POST['hours2']; $course2 = ($_POST['mark2']) * $hour2; } if($_POST['mark3'] == 0 ){ $course3 = 0; }else{ $hour3=$_POST['hours3']; $course3 = ($_POST['mark3']) * $hour3; } if($_POST['mark4'] == 0 ){ $course4 = 0; }else{ $hour4=$_POST['hours4']; $course4 = ($_POST['mark4']) * $hour4 ; } if($_POST['mark5'] == 0 ){ $course5 = 0; }else{ $hour5=$_POST['hours5']; $course5 = ($_POST['mark5']) * $hour5; } if($_POST['mark6'] == 0 ){ $course6 = 0; }else{ $hour6=$_POST['hours6']; $course6 = ($_POST['mark6']) *$hour6 ; } if($_POST['mark7'] == 0 ){ $course7 = 0; }else{ $hour7=$_POST['hours7']; $course7=($_POST['mark7'])*$hour7; } if($_POST['mark8'] == 0 ){ $course8 = 0; }else{ $hour8=$_POST['hours8']; $course8 = ($_POST['mark8']) * $hour8 ; } $sum = $course1 + $course2 + $course3 + $course4 + $course5 + $course6 + $course7 + $course8; return $sum; } function final_sum(){ $total = pre_sum()+new_sum(); if($_POST['mark1'] == 0 ){ $course1 = 0; }else{ $hour1=$_POST['hours1']; $course1 = ($_POST['repeat1']) * $hour1; } if($_POST['mark2'] == 0 ){ $course2 = 0; }else{ $hour2=$_POST['hours2']; $course2 = ($_POST['repeat2']) * $hour2; } if($_POST['mark3'] == 0 ){ $course3 = 0; }else{ $hour3=$_POST['hours3']; $course3 = ($_POST['repeat3']) * $hour3; } if($_POST['mark4'] == 0 ){ $course4 = 0; }else{ $hour4=$_POST['hours4']; $course4 = ($_POST['repeat4']) * $hour4 ; } if($_POST['mark5'] == 0 ){ $course5 = 0; }else{ $hour5=$_POST['hours5']; $course5 = ($_POST['repeat5']) * $hour5; } if($_POST['mark6'] == 0 ){ $course6 = 0; }else{ $hour6=$_POST['hours6']; $course6 = ($_POST['repeat6']) *$hour6 ; } if($_POST['mark7'] == 0 ){ $course7 = 0; }else{ $hour7=$_POST['hours7']; $course7=($_POST['repeat7'])*$hour7; } if($_POST['mark8'] == 0 ){ $course8 = 0; }else{ $hour8=$_POST['hours8']; $course8 = ($_POST['repeat8']) * $hour8 ; } $min = $course1 + $course2 + $course3 + $course4 + $course5 + $course6 + $course7 + $course8; $final = $total - $min ; return $final; } function final_hours(){ $total = pre_hours() + new_hours(); if($_POST['repeat1'] == 0 || $_POST['mark1'] == 0){ $hour1 = 0; } else $hour1=$_POST['hours1']; if($_POST['repeat2'] == 0 || $_POST['mark2'] == 0 ){ $hour2 = 0; }else{ $hour2=$_POST['hours2']; } if($_POST['repeat3'] == 0 || $_POST['mark3'] == 0 ){ $hour3 = 0; }else{ $hour3=$_POST['hours3']; } if($_POST['repeat4'] == 0 || $_POST['mark4'] == 0 ){ $hour4 = 0; }else{ $hour4=$_POST['hours4']; } if($_POST['repeat5'] == 0 || $_POST['mark5'] == 0 ){ $hour5 = 0; }else{ $hour5=$_POST['hours5']; } if($_POST['repeat6'] == 0 || $_POST['mark6'] == 0 ){ $hour6 = 0; }else{ $hour6=$_POST['hours6']; } if($_POST['repeat7'] == 0 || $_POST['mark7'] == 0 ){ $hour7 = 0; }else{ $hour7=$_POST['hours7']; } if($_POST['repeat8'] == 0 || $_POST['mark8'] == 0 ){ $hour8 = 0; }else{ $hour8=$_POST['hours8']; }{ $min = $hour1 + $hour2 + $hour3 + $hour4 + $hour5 + $hour6 + $hour7 + $hour8 ; $final = $total - $min ; return $final; } function avg(){ if (new_hours() == 0 ){ return 0; } else{ $f = new_sum()/new_hours(); return $f; } } function GPA(){ if(pre_hours() == 0 || pre_gpa() == 0 ) return null; if (final_hours() ==0 ){ return 0; }else{ $f = final_sum()/final_hours(); return $f; }} ?>
I need to convert my PHP code to JavaScript, how do I do it? Because I am making an website and I can't use php.i want use js plz
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)