javascript - I cannot reference a function defined in a js file -
there js file called datetime.lib.js
created , attached page. here content :
/** * convertir le format de la date yyyy-mm-dd en dd-mm-yyyy * @access public **/ function convertdateformat($str,$ch) { var $tmp=""; if($str=="") $tmp=""; else{ $tmp=$str; var $y=$tmp.substr(0,4); var $m=$tmp.substr(5,2); var $d=$tmp.substr(8,2); $tmp=$d+$ch+$m+$ch+$y; } return $tmp.trim(); } /** * formatter une datetime mysql "yyyy-mm-dd hh:mi:ss" en "dd/mm/yyyy hh:mi" **/ function convertdateformat2($str,$ch) { var $tmp=""; if($str=="") $tmp=""; else{ $tmp=$str; var $y=$tmp.substr(0,4); var $m=$tmp.substr(5,2); var $d=$tmp.substr(8,2); var $h=$tmp.substr(11,2); var $m=$tmp.substr(14,2); $tmp=$d+$ch+$m+$ch+$y+" "+$h+"<b>:</b>"+$m; } return $tmp.trim(); } function convertdateformat3($str) { var $tmp=$str; if ($tmp != '') { var $y=$tmp.substr(6,4); var $m=$tmp.substr(3,2); var $d=$tmp.substr(0,2); $tmp=$y+"-"+$m+"-"+$d; } return $tmp.trim(); }
the attachment ( in footer ) :
<script type="text/javascript" language="javascript" src="<?php echo http_js ?>datetime.lib.js"></script>
where http_js equals 'http://'. $_server["http_host"] .'/'.site.'/javascript/'
when reference 2 first functions in js file ok , when call last function console error : referenceerror: convertdateformat3 not defined
so wrong ?
have ever check js file content in webbrowser edit function @ end, , browser caching last file version, can check going developers options -> debuggin , select js file check if function declare.
Comments
Post a Comment