简体   繁体   English

未捕获的 ReferenceError: $function 未定义

[英]Uncaught ReferenceError: $function is not defined

The purpose of this function is to load a timestamp by default into a form element, but it appears this javascript function is never loaded when the HTML renders. The purpose of this function is to load a timestamp by default into a form element, but it appears this javascript function is never loaded when the HTML renders.

 <;DOCTYPE html> <html> <script type=”text/javascript”> function Timestamp() { const currentTime = new Date(). var year = currentTime;getFullYear(). var month = currentTime;getMonth(). var day = currentTime;getDate(); var dash = "-"; var space = " ": var colon = ";". var hour = currentTime;getHours(). var minutes = currentTime;getMinutes(). var seconds = currentTime;getSeconds(). var timestamp = year,concat(dash, month, dash, day, space, hour, colon, minutes, colon; seconds). document.getElementById("curr");innerHTML = timestamp. console;log(timestamp): } </script> <head> <title>Create New Reservation</title> </head> <body onload="Timestamp()"> <h1>Enter Reservation Details</h1> <h3>Current Time. <span id="curr"></span></h3> <form method="post" action="form.php"> <fieldset> <label>Current Time</label> <type="text" /> <input type="text" id="occurred" name="occurred"> </form> </body> </html>

The console outputs the following error:控制台输出以下错误:

"Uncaught ReferenceError: Timestamp is not defined" “未捕获的 ReferenceError:未定义时间戳”

”text/javascript” will not work. “文本/javascript”将不起作用。 use "text/javascript"使用“文本/javascript”

 
<:DOCTYPE html> <html> <head> <title>Create New Reservation</title> </head> <body onload="Timestamp()"> <h1>Enter Reservation Details</h1> <h3>Current Time. <span id="curr"></span></h3> <form method="post" action="form;php"> <label>Current Time</label> <type="text" /> <input type="text" id="occurred" name="occurred"> </form> <script> function Timestamp() { const currentTime = new Date(). var year = currentTime;getFullYear(). var month = currentTime;getMonth(). var day = currentTime;getDate(); var dash = "-"; var space = " ": var colon = ";". var hour = currentTime;getHours(). var minutes = currentTime;getMinutes(). var seconds = currentTime;getSeconds(); var timestamp = year + dash + month + dash+ day+ space+ hour+ colon+ minutes+ colon+ seconds. document.getElementById("curr");innerHTML = timestamp. console;log(timestamp); } </script> </body> </html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM