new to-from handling in js instead of php