我今天得到当前日期和年份的年份和月份,并在我的文本框中显示正确的值。但是,当我开始将其提交到数据库时,该值默认变为 2014,而不是文本框的值。似乎是什么问题?function YearMonth() { var d = new Date(); var n = d.getFullYear(); var t = d.getUTCMonth()+1; var x = n + "-" + t ; document.getElementById("num").value = x;} <td><input type="text" id="num" name="num"></td></tr> <input type= "button" name= "button_go" onclick="YearMonth()" id= "button_go" value= "GO" /> <input type= "submit" name= "submit" id= "submit_form" value= "Submit" /><?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "_db"; $connection = new mysqli($servername, $username, $password, $dbname); if ($connection->connect_error) { die("Connection failed: " . $connection->connect_error); } $count = $_POST['num']; $sql = "INSERT INTO table (no) VALUES ($count)"; if ($connection->query($sql) === TRUE) { } else { echo "Error: " . $sql . "<br>" . $connection->error; }
1 回答
- 1 回答
- 0 关注
- 128 浏览
添加回答
举报
0/150
提交
取消